当前位置:Gxlcms > PHP教程 > 直接访问链接有数据,CURLGET一片空白

直接访问链接有数据,CURLGET一片空白

时间:2021-07-01 10:21:17 帮助过:87人阅读

$url='http://114.215.198.210:8081/a...';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_HEADER, 0); // 不要http header 加快效率
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
echo $output = curl_exec($ch);
curl_close($ch);

回复内容:

$url='http://114.215.198.210:8081/a...';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_HEADER, 0); // 不要http header 加快效率
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
echo $output = curl_exec($ch);
curl_close($ch);

我试了下怎么没问题:

➜  /tmp php test.php
{"status":"0","msg":"操作成功","result":{"locationTimeStamp":1468311789000,"address":"广东省深圳市南山区高新南三道靠近真功夫(南山科技园店)","stepValue":0,"calory":0,"distance":0,"radius":70,"deviceId":"666666666666675","battery":66,"positionType":2,"lat":22.538201,"lng":113.952924},"timestamp":1470463701045}%

test.php就是你帖的代码:

结果为字符串且
输出到屏幕上 curl_setopt($ch, CURLOPT_HEADER, 0); // 不要http header 加快效率 curl_setopt($ch, CURLOPT_TIMEOUT, 15); echo $output = curl_exec($ch); curl_close($ch); ?>

人气教程排行