[英]PHP cURL GET Request to REST API not returning anything
I'm trying to use the UMLS Search REST API .我正在尝试使用UMLS 搜索 REST API 。 I successfully retrieved the TGT and The ST.我成功检索了 TGT 和 ST。 However, when trying to do a search as mentioned in the documentations, I got no response at all.但是,当尝试按照文档中所述进行搜索时,我根本没有得到任何回应。 Here's my code:这是我的代码:
<?php
$service_ticket='xxx' //ST retrieve earlier
$cURLConnection = curl_init();
curl_setopt($cURLConnection, CURLOPT_URL,"https://uts-ws.nlm.nih.gov/rest/search/current");
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
//avoid unable to get local issuer certificate
$values = array(
'ticket' => $service_ticket,
'string' => 'C0162565'
);
$params = http_build_query($values);
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
$qresult = curl_exec($cURLConnection);
curl_close($cURLConnection);
$jsonArrayResponse = json_decode($qresult,true);
print_r($jsonArrayResponse);
?>
The API expects a GET request, but using curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
API 需要 GET 请求,但使用curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
is changing the request type to POST.正在将请求类型更改为 POST。 removing this command and adding the parameters directly to the URL fixes the problem.删除此命令并将参数直接添加到 URL 可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.