PHP code example of onlime / laravel-bexio-api-client
1. Go to this page and download the library: Download onlime/laravel-bexio-api-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
onlime / laravel-bexio-api-client example snippets
namespace App\Http\Controllers;
use Bexio\Resource\Contact as BexioContact;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Inertia\Inertia;
use LaravelBexio\Client;
class BexioController extends Controller
{
public function authenticate(Request $request)
{
$client = $this->getBexioClient();
$client->authenticate(config('bexio.api.scopes'), route('bexio.auth'));
$client->persistTokens($this->getTokensFile());
return view('bexio.auth');
}
public function demo(Request $request)
{
$client = $this->getBexioClient();
$client->loadTokens($this->getTokensFile());
return view('bexio.demo', [
'contacts' => (new BexioContact($client))->getContacts(),
]);
}
protected function getBexioClient(): Client
{
return new Client(
config('bexio.api.clientId'),
config('bexio.api.clientSecret')
);
}
protected function getTokensFile(): string
{
return Storage::disk('secure')->path(config('bexio.api.tokensFile'));
}
}
$ php artisan serve
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.