1. Go to this page and download the library: Download amcintosh/freshbooks 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/ */
amcintosh / freshbooks example snippets
use Spryker\DecimalObject\Decimal;
$this->assertEquals(Decimal::create('41.94'), $invoice->amount->amount);
use amcintosh\FreshBooks\FreshBooksClient;
use amcintosh\FreshBooks\FreshBooksClientConfig;
$conf = new FreshBooksClientConfig(
clientSecret: 'your secret',
redirectUri: 'https://some-redirect',
);
$freshBooksClient = new FreshBooksClient('your application id', $conf);
use amcintosh\FreshBooks\FreshBooksClient;
use amcintosh\FreshBooks\FreshBooksClientConfig;
$conf = new FreshBooksClientConfig(
accessToken: 'a valid token',
);
$freshBooksClient = new FreshBooksClient('your application id', $conf);
echo $authResults->accessToken; // Your token
echo $authResults->refreshToken; // Your refresh token
echo $authResults->createdAt; // When the token was created (as a DateTime)
echo $authResults->expiresIn; // How long the token is valid for (in seconds)
echo $authResults->getExpiresAt; // When the token expires (as a DateTime)
echo $freshBooksClient->getConfig()->accessToken; // Your token
echo $freshBooksClient->getConfig()->refreshToken; // Your refresh token
echo $freshBooksClient->getConfig()->tokenExpiresAt; // When the token expires (as a DateTime)
$authResults = $freshBooksClient->refreshAccessToken();
echo $authResults->accessToken; // Your new token
$authResults = $freshBooksClient->refreshAccessToken($storedRefreshToken);
echo $authResults->accessToken; // Your new token
$identity = $freshBooksClient->currentUser()
echo $identity.email // prints the current user's email
// Print name and role of each business the user is a member of
foreach ($identity.businessMemberships as $businessMembership) {
echo $businessMembership->business.name
echo $businessMembership->role; // eg. owner
}