You are here

public function BiblioEntrezClient::fetch in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/pubmed/EntrezClient.php \BiblioEntrezClient::fetch()
  2. 6 pubmed/EntrezClient.php \BiblioEntrezClient::fetch()
  3. 7.2 modules/pubmed/EntrezClient.php \BiblioEntrezClient::fetch()

Returns the document identified by the given PubMed ID as a SimpleXMl object. The root element is PubmedArticleSet.

Parameters

int $id:

Return value

SimpleXMLElement

File

modules/pubmed/EntrezClient.php, line 388
Provides Entrez client to retrieve items from the NCBI databases.

Class

BiblioEntrezClient

Code

public function fetch($id) {
  $params['db'] = $this
    ->getDatabase();
  $params['retmode'] = 'xml';
  $params['id'] = $id;
  $this->query = self::BASE_URL . 'efetch.fcgi?' . http_build_query($params);
  $request_options = array(
    'method' => 'POST',
  );
  $result = drupal_http_request($this->query, $request_options);
  if ($result->code != 200) {
    throw new Exception('Query ' . $this->query . ' failed.');
  }
  $result = @simplexml_load_string($result->data);
  if (!$result) {
    throw new Exception('Query ' . $this->query . ' failed.');
  }
  return $result;
}