1. Go to this page and download the library: Download yireo/producteev-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/ */
yireo / producteev-client example snippets
// Include all composer packages
ts ID and secret
$client = new \Yireo\ProducteevClient\Client($clientId, $clientSecret);
// Retrieve a current access token from cookie, if there
$client->retrieveAccessTokenFromCookie();
// Set the redirect URL
$redirectUrl = 'http://example.com/';
$client->setRedirectUrl($redirectUrl);
// When authenticating via OAuth2, Producteev will redirect back to us with a "code" set
if (!empty($_REQUEST['code'])) {
$client->setAuthenticationCode($_REQUEST['code']);
$client->retrieveAccessTokenToCookie();
// Redirect to our same page again, removing the "code" part
header('Location: ' . $redirectUrl);
exit;
}
// When there is no valid access token, this will initiate OAuth2 authentication including a redirect to the Producteev webpage
if($client->isAccessTokenValid() === false) {
$client->authenticate();
}
// Example call
echo '<pre>';
print_r($client->getResource('users')->me());
echo '</pre>';