Home > Backend Development > PHP Tutorial > 利用php的curl获取不到新浪的API数据解决方案

利用php的curl获取不到新浪的API数据解决方案

WBOY
Release: 2016-06-13 12:29:35
Original
987 people have browsed it

利用php的curl获取不到新浪的API数据
我拼接了新浪的API,来获取微博的一些数据。这是我拼接出来的链接:
https://api.weibo.com/2/statuses/repost_timeline.json?id=3681834027857481&page=1&count=100&access_token=2.00Oa6w2CHIARMB96820f87ebEnJkeE
如果直接在浏览器输入这个链接,室友数据的,但是:我如果用crul函数时却拿不到
以下是我的函数:(注:那个$url就是上面的那条链接)
               $ch = curl_init();
// 2. 设置请求选项, 包括具体的url
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. 执行一个cURL会话并且获取相关回复
 $response = curl_exec($ch);
// 4. 释放cURL句柄,关闭一个cURL会话
curl_close($ch);
我打印出来的$response 值是false,求解各位大神加上
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

协议头 https
curl 默认开启证书验证
所以应关闭之

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template