【发布时间】:2012-06-24 23:12:16
【问题描述】:
我正在运行一个 php 网站,并希望从我的公司 Twitter 提要中提取最新的推文。以下是我拥有的代码,但它目前无法正常工作。我做错了什么?我是否需要更改 Twitter 中的任何设置才能使此方法起作用?
$responseJson = file_get_contents('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=take_me_fishing&include_rts=1&count=1');
if ($responseJson)
{
$response = json_decode($responseJson);
$status = $response->text;
}
【问题讨论】:
-
“不工作”是什么意思?发生什么了?代码看起来不错。也许,
file_get_contents失败是因为php.ini中的指令阻止通过网络读取数据? -
您无需更改 Twitter 设置中的任何内容。尝试在浏览器中打开 URL。有用。你的 php 代码一定有问题。
-
感谢大家的快速回复!事实证明,它就像缺少数组括号一样简单。
标签: php json twitter feed tweets