1. Go to this page and download the library: Download olendorf/ezid-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/ */
olendorf / ezid-php example snippets
/**
* Using ezid.json configuration
*/
$client = new ezid\Connection();
/**
* Overriding or not using ezid.json
*/
$config = array(
"username"=>"RandomCitizen",
"password"=>"foobar123",
"doi_shoulder"=>"doi:10.5072/FK2", # optional and make sure you use the right shoulder.
"ark_shoulder"=>""ark:/99999/fk4" # same as above
);
$client = new ezid\Connection($config);
// Getting Server Status
$response = $this->status();
echo $response->getBody()->getContents(); // success: EZID is up
// Creating an identifier
$meta = [
"creator" => 'Random Citizen',
'title' => 'Random Thoughts',
'publisher' => 'Random Houses',
'publicationyear' => '2015',
'resourcetype' => 'Text'
];
$identifier = $client->doi_shoulder.uniqid(); // Just using uniqid() to generate a unique string.
$response = $client->create($identifier, $meta);
echo $response->GetStatusCode(); // 201
// Minting an identifier
$response = $client->mint('doi', $meta); //uses the shoulder specified in config or on creation of the client.
echo $response->GetStatusCode(); // 201
$response = $client->get_identifier_metadata($identifier); // will get the meta sent in create()
echo (string)$response->getBody(); // Key value pair formatted string with metadata
// datacite.creator: Random Citizen
// datacite.title : Random Thoughts
// ...
// You can extract this using parse_response_metadata()
$meta_array = $client->parse_response_metadata((string)$response->getBody()); // Guzzle returns a stream, cast it to a string
print_r($meta_array);
// (
// [datacite.creator] => 'Random Citizen',
// [datacite.title] => 'Random Thoughts',
// ...
// )