0

I am using Laravel 5.5 to develop a Student Project. There is an option in my project where the publication information can be found by searching with DOI. I am using the below code but it stops working.

function doi_url($doi)
{
  return "http://dx.doi.org/" . $doi;
}

function get_curl($url) 
{ 
  $curl = curl_init(); 
  $header[0] = "Accept: application/rdf+xml;q=0.5,"; 
  $header[0] .= "application/vnd.citationstyles.csl+json;q=1.0"; 
  curl_setopt($curl, CURLOPT_URL, $url); 
  curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)'); 
  curl_setopt($curl, CURLOPT_HTTPHEADER, $header); 
  curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com'); 
  curl_setopt($curl, CURLOPT_AUTOREFERER, true); 
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($curl, CURLOPT_TIMEOUT, 10); 
  $citation_string = curl_exec($curl); 
  curl_close($curl); 
  return $citation_string; 
}

function get_json_array($json)
{
  return json_decode($json, true);
}
  echo doi_url($doi);
  echo get_curl($doi_url);
   echo  get_json_array($json);
  echo  $json_array["container-title"];
  echo  $json_array["page"];
   echo  $json_array["issue"];
   echo  $json_array["ISSN"];
   echo  $json_array["URL"];
  echo  $json_array["issued"]["date-parts"][0][0];

Please help me is there any other procedure to get publication data?

  • Can you give an example for `$json` in your `echo get_json_array($json);` line? And: Shouldn't you do something like `$doi_url = doi_url($doi);` instead of just `echo`-ing the function? – anpami Oct 20 '22 at 18:16

0 Answers0