【发布时间】:2016-10-29 19:28:53
【问题描述】:
这是下面的 url,用 file_get_contents 和 curl 方法都试过了……在 php 脚本中不起作用,但在 postman 中可以正常工作。 知道为什么会这样吗???
https://query.yahooapis.com/v1/public/yql?q= select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(28.56,77.32)") and u='c'&format=json
cURL请求如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
// convert response
$output = json_decode($output);
// handle error; error output
if(curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
var_dump($output);
}
echo curl_error($ch);
curl_close($ch);
【问题讨论】:
-
file_get_contents 不适用于 https
-
请为请求添加您的 curl 代码。
-
edited..with curl