1. Go to this page and download the library: Download mradcliffe/xeroclient 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/ */
mradcliffe / xeroclient example snippets
// Create a new provider.
$provider = new \Radcliffe\Xero\XeroProvider([
'clientId' => 'my consumer key',
'clientSecret' => 'my consumer secret',
'redirectUri' => 'https://example.com/path/to/my/xero/callback',
// This will always request offline_access.
'scopes' => \Radcliffe\Xero\XeroProvider::getValidScopes('accounting'),
]);
// Gets the URL to go to get an authorization code from Xero.
$url = $provider->getAuthorizationUrl();
$client = \Radcliffe\Xero\XeroClient::createFromToken('my consumer key', 'my consumer secret', $code, 'authorization_code', 'accounting');
// Store the access token for the next 30 minutes or so if making additional requests.
$tokens = $client->getRefreshedToken();