ostapdontstop

phhph

Jun 27th, 2021
926
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get_from_mendeley($doi)
  2. {
  3.     $str = '[{"operationName":"facets","variables":{"searchQuery":"'.$doi.'","facets":{"publicationType":[],"publicationYear":[],"accessType":[],"publishedIn":[],"authorFullName":[]},"facetsTouched":[]},"query":"query facets($searchQuery: String!, $facets: FacetsInput!, $facetsTouched: [FacetTouchedInput]!, $startDate: String, $endDate: String) {\n  facets(searchQuery: $searchQuery, facets: $facets, facetsTouched: $facetsTouched, startDate: $startDate, endDate: $endDate) {\n    searchQuery\n    facets {\n      publicationYear {\n        ...facetFragment\n        __typename\n      }\n      publicationType {\n        ...facetFragment\n        __typename\n      }\n      publishedIn {\n        ...facetFragment\n        __typename\n      }\n      accessType {\n        ...facetFragment\n        __typename\n      }\n      authorFullName {\n        ...facetFragment\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n\nfragment facetFragment on FacetItem {\n  id\n  count\n  label\n  name\n  isApplied\n  __typename\n}\n"}]';
  4.  
  5.     $data = json_decode($str, true);
  6.     $url = 'https://www.mendeley.com/search/graphql';
  7.     $options = array(
  8.         'http' => array(
  9.             'header'  => "Content-type: application/json\r\n",
  10.             'method'  => 'POST',
  11.             'content' => $str
  12.         )
  13.     );
  14.     $context  = stream_context_create($options);
  15.     $result = file_get_contents($url, false, $context);
  16.     if ($result === FALSE) { return false; }
  17.  
  18.     return json_decode($result,true);
  19. }
RAW Paste Data