Trying to get the NCTId, BriefTitle, BriefSummary and OverallStatus parameters to be displayed on a page. But I am having a hard time just getting the parameters.
I am new to JSON, so any help appreciated.
I tried this to see if the BriefTitle would display:
$url='https://clinicaltrials.gov/api/query/field_values?expr=heart+attack&field=BriefTitle&fmt=json';
$JSON = file_get_contents($url);
$response_json_data = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($JSON, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($response_json_data as $key => $val) {
if(!is_array($val)) {
if($key == "BriefTitle") {
print "<br/>";
}
print $key." : ".$val . "<br/>";
}
}
<?php $url='https://clinicaltrials.gov/api/query/full_studies?expr=heart+attack&fields=NCTId,BriefTitle,BriefSummary,CollaboratorName&fmt=json'; $JSON = json_decode(file_get_contents($url), true); echo($JSON["FullStudiesResponse"]["FullStudies"][0]["Study"]["ProtocolSection"]["IdentificationModule"]["NCTId"]);