Given an InChI (structure-based identifier for a molecule), retrieve information for that compound from PubChem [Wikipedia]:
//$inchi = '1/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3';
if ($search = simplexml_load_file("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?usehistory=y&db=pccompound&term=\"InChI={$inchi}\"[InChI]")){
if ($pubchem = simplexml_load_file("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?retmax=1&retmode=xml&db=pccompound&query_key={$search->QueryKey}&WebEnv={$search->WebEnv}")){
print dump_pubchem($pubchem->DocSum);
}
}
function dump_pubchem($object, $name = NULL){
$items = array();
foreach ($object->Item as $item){
switch ($item['Type']){
case 'List':
$items[] = dump_pubchem($item, $item['Name']);
break;
case 'String': case 'Integer': default:
$items[] = $name ? (string) $item : sprintf("%s: %s", $item['Name'], $item);
break;
}
}
return sprintf("%s:\n%s\n", $name, implode("\n", $items));
}