我有一个返回JSON的网址。
$url = "http://115.249.245.30:9001/speeddial/api/d2h.php"
$queryString = "?ANI=9810652710&RTN1=Uttar+Pradesh&RTN2=Bill+Related&PL=234&CustID=ASDIOASD&EmailID=&CustName=XXXX&AgentName1=Naveen&ComplaintId=101&Category=SMS&DateTime=10Apr%202015&CallTime=2016-04-30+14%3A45%3A00"
窗口上的Curl调用可以在ubuntu系统上运行,但这不会返回任何内容
这是进行此URL调用的方法片段
static function httpCurlCall($url, $querystring)
{
$urlfinal = $url.$querystring;
$ch = curl_init($urlfinal);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
if(curl_errno($ch)){ // this is to debug
echo 'Curl error: ' . curl_error($ch);
}
print_r(curl_getinfo($ch)); // this is to debug
curl_close($ch);
return $result;
}
另外,直接调用URL会返回正确的结果。
Error response on debug : Curl error: Failed to connect to 115.249.245.30 port 9001: Connection timed out
我哪里错了。