【发布时间】:2012-12-10 14:06:35
【问题描述】:
所以我正在测试变量是否返回指定用户的屏幕名称 tweets 的 JSON 数据.. 但它没有返回任何内容,我使用了正确的 get 方法.. 我哪里出错了.. 下面是代码..
<?php
$url= "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=agasaro&count=5";
$results = json_decode(file_get_contents($url));
var_dump($results);
VAR_DUMP 返回这个
Warning: file_get_contents(http://api.twitter.com/1/statuses/user_timeline.json?screen_name=agasaro&count=5) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in
【问题讨论】:
-
您是否检查过您的互联网连接或代理设置(如果您正在使用它们)?您可以从浏览器访问 twitter.com 吗?
-
在浏览器中粘贴url,看看是否在浏览器中得到输出
-
@praveen 是的,浏览器上的 URL 返回数据.. 但代码不会