1. Go to this page and download the library: Download qeios-lab/orcid-php 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/ */
qeios-lab / orcid-php example snippets
// Set up the config for the ORCID API instance
$oauth = new Oauth;
$oauth->setClientId($clientId)
->setScope('/authenticate')
->setState($state)
->showLogin()
->setRedirectUri($redirectUri);
// Create and follow the authorization URL
header("Location: " . $oauth->getAuthorizationUrl());
if (!isset($_GET['code']))
{
// User didn't authorize our app
throw new Exception('Authorization failed');
}
$oauth = new Oauth;
$oauth->setClientId($clientId)
->setClientSecret($clientSecret)
->setRedirectUri($redirectUri);
// Authenticate the user
$oauth->authenticate($_GET['code']);
// Check for successful authentication
if ($oauth->isAuthenticated())
{
$orcid = new Profile($oauth);
// Get ORCID iD
$id = $orcid->id();
}
$orcid = new Profile($oauth);
// Get ORCID profile details
$id = $orcid->id();
$email = $orcid->email();
$name = $orcid->fullName();
$oauth = new Oauth;
$oauth->useMembersApi();
$oauth = new Oauth;
$oauth->usePublicApi();
$oauth = new Oauth;
$oauth->useSandboxEnvironment();
$oauth = new Oauth;
$oauth->useProductionEnvironment();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.