Minimal PHP script for downloading PubMed XML

·
Actually that wasn't a really minimal script for downloading PubMed XML data; this is:
<?php
$query = '"genetics"[MeSH] AND "Nature"[TA]'; // for example
$params = array(
  'db' => 'pubmed',
  'retmode' => 'xml',
  'retmax' => 1,
  'usehistory' => 'y',
  'term' => $query,
  );
$xml = simplexml_load_file('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?' . http_build_query($params));
$params = array(
  'db' => 'pubmed',
  'retmode' => 'xml',
  'query_key' => (string) $xml->QueryKey,
  'WebEnv' => (string) $xml->WebEnv,
  'retmax' => (int) $xml->Count,
  );
 
$url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' . http_build_query($params);
file_put_contents('pubmed.xml', file_get_contents($url));
It's the equivalent of this Yahoo! Pipe.