PHP code example of renanbr / crossref-client

1. Go to this page and download the library: Download renanbr/crossref-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/ */

    

renanbr / crossref-client example snippets


class RenanBr\CrossRefClient
{
    // Returns JSON decoded as array
    public function request($path, array $parameters = []);

    // Returns boolean
    public function exists($path);

    public function setUserAgent($userAgent);
    public function setCache(Psr\SimpleCache\CacheInterface $cache);
    public function setVersion($version);
}


$client = new RenanBr\CrossRefClient();
$work = $client->request('works/10.1037/0003-066X.59.1.29');
print_r($work);


$client = new RenanBr\CrossRefClient();
$exists = $client->exists('members/98');
var_dump($exists);


$client = new RenanBr\CrossRefClient();

$parameters = [
    'query' => 'global state',
    'filter' => [
        'has-orcid' => true,
    ],
];
$result = $client->request('works', $parameters);

foreach ($result['message']['items'] as $work) {
    // ...
}


$client = new RenanBr\CrossRefClient();
$client->setCache(new voku\cache\CachePsr16());

// ...


$client = new RenanBr\CrossRefClient();
$client->setUserAgent('GroovyBib/1.1 (https://example.org/GroovyBib/; mailto:[email protected])');

// ...


$client = new RenanBr\CrossRefClient();
$client->setVersion('v55');

// ...