1. Go to this page and download the library: Download maicol07/orcid-php-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/ */
maicol07 / orcid-php-client example snippets
use Orcid\Oauth;
use Orcid\ApiScopes;
// Set up the config for the ORCID API instance
$oauth = (new Oauth($clientId, $clientSecret))
->scopes(ApiScopes::AUTHENTICATE)
->state($state)
->redirectUri($redirectUri)
->showLogin(true);
// Create and follow the authorization URL
header("Location: " . $oauth->getAuthorizationUrl());
use Orcid\Oauth;
use Orcid\ApiScopes;
if (!isset($_GET['code'])) {
// User didn't authorize our app
throw new Exception('Authorization failed');
}
// Set up the config for the ORCID API instance
$oauth = (new Oauth($clientId, $clientSecret))
->redirectUri($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();
}
use Orcid\Profile;
$orcid = new Profile($oauth);
// Get ORCID profile details
$id = $orcid->id();
$email = $orcid->email();
$name = $orcid->fullName();
use Orcid\Oauth;
$oauth = (new Oauth())->membersApi(true);
use Orcid\Oauth;
$oauth = (new Oauth())->membersApi(false);
use Orcid\Oauth;
$oauth = (new Oauth())->sandbox(true);
use Orcid\Oauth;
$oauth = (new Oauth())->sandbox(false);
use Orcid\Work\Work;
use Orcid\Work\WorkType;
use PrinsFrank\Standards\Language\ISO639_1_Alpha_2;
use Orcid\Work\CitationType;
use PrinsFrank\Standards\Country\ISO3166_1_Alpha_2;
use Orcid\Work\ContributorRole;
use Orcid\Work\ContributorSequence;
// creation of an Orcid work
$work = (new Work())
->title("Les stalagmites du réseau du trou Noir")
->translatedTitle('The stalagmites of the Black hole network')
->translatedTitleLanguageCode(ISO639_1_Alpha_2::English) // These three methods about the title can be shortened to the first one (3 params)
->type(WorkType::WORKING_PAPER)
->url("the work url")
->journalTitle("naturephysic")
->citation("The work citation....")//if you don't set citationType formatted-unspecified will be set
->citationType(CitationType::FORMATTED_UNSPECIFIED)
->shortDescription("the work description...") // the description must be less than 500 characters
->publicationDate(\Carbon\Carbon::createFromDate(1998, 09, 20)) // the first parameter year is
use Orcid\Work\Work;
use Orcid\Work\WorkType;
// minimum configuration to create an Orcid work
$work = (new Work())
->title("Les stalagmites du réseau du trou Noir")
->type(WorkType::WORKING_PAPER)
->addExternalId("doi", "10.1038/nphys1170");
$putCode = 14563;
$work->putcode($putCode);
use Orcid\Work\Works;
$works = new Works([$work1, $work2, $work3]);
// Or via the append method:
$works->append($firstwork);
$works->append($secondwork);
$works->append($thirdwork);
use Orcid\Work\Work;
foreach ($works as $work){
assert($work instanceof Work);
$work->addContributor("Authorfullname", \Orcid\Work\ContributorRole::AUTHOR, "Author orcid ID", \Orcid\Work\ContributorSequence::FIRST);
}
use Orcid\Work\OClient;
// Check for successful authentication
if ($oauth->isAuthenticated())
{
// creation of an orcid client
$orcidClient = new OClient($oauth);
}
use Orcid\Work\OClient;
// send one or several work(s)
/** @var Work|Works|Work[] $works */
/** @var OClient $orcidClient */
$orcidClient->send($works);
use Orcid\Work\OClient;
// update a Work
/** @var OClient $orcidClient */
/** @var OClient $orcidClient */
$orcidClient->update($work);
use Orcid\Work\OClient;
// delete a Work
$putcode=14563;
/** @var OClient $orcidClient */
$orcidClient->delete($putcode);
use Orcid\Work\Works;
/** @var \Orcid\Work\OResponse $OResponse */
if ($OResponse->hasSuccess()) {
/** @var Records $recordWorkList */
$recordWorkList = $OResponse->getWorkRecordList();
}
use Orcid\Work\Works;
use Orcid\Work\Work;
/** @var Works $works */
// Returns date of last modification of ORCID registrations
$grouplastModifiedDate = $works->lastModifiedDate();
// returns a complex associative array coming directly from Orcid and containing the information on the work read.
$group = $works->getOrcidWorks();
foreach ($works as $work){
assert($work instanceof Work);
$putCode= $work->putCode();
$workSource = $work->source();
$workPath = $work->path();
$lastModifiedDate = $work->lastModifiedDate(); // returns date of last modification of this record work
$title = $work->title();
// returns an external identifier array of type ExternalId
$externalIds = $work->externals();
}
use Orcid\Work\ExternalId;
use Orcid\Work\Work;
/** @var Work $record */
$externalIds= $record->externals();
foreach ($externalIds as $externalId){
assert($externalId instanceof ExternalId);
$idType = $externalId->type();
$idValue = $externalId->value();
$idUrl = $externalId->url();
$idRelationship = $externalId->relationship();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.