PHP code example of shippinno / oauth2-next-engine
1. Go to this page and download the library: Download shippinno/oauth2-next-engine 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/ */
shippinno / oauth2-next-engine example snippets
$provider = new \Shippinno\NextEngine\OAuth2\Client\Provider\NextEngineProvider([
'clientId' => '{next-engine-client-id}',
'clientSecret' => '{next-engine-lient-secret}',
'redirectUri' => 'https://example.com/callback',
]);
if (!isset($_GET['uid']) || !isset($_GET['state'])) {
$authUrl = $provider->getAuthorizationUrl();
header('Location: '.$authUrl);
exit;
} else {
$token = $nextEngineProvider->getAccessToken('client_credentials', [
'uid' => $_GET['uid'],
'state' => $_GET['state']
]);
try {
$user = $provider->getResourceOwner($token);
printf('Hello %s!', $user->getCompanyName());
} catch (Exception $e) {
exit('Oh dear...');
}
echo $token->getToken();
}