【问题标题】:twitter api problem推特接口问题
【发布时间】:2011-03-24 22:03:24
【问题描述】:

我已经搜索了整个网络以找到一个好的和简单的方法来获得推特状态,现在我找到了一个..但它不起作用

我试试这个 http://tareq.wedevs.com/2009/05/playing-with-twitter-json-using-php/

但它说

“注意:使用未定义的常量文本 - 在第 8 行 /Applications/MAMP/htdocs/test/twitterWidget/twitter.php 中假定为“文本”

iPad2 模拟器 /w Css3、Jquery 和 HTML5 http://t.co/GaNMTbg via @altryne"

我需要做什么?

【问题讨论】:

  • 你应该接受更多的答案。
  • 我们绝对需要看到代码失败的部分才能帮助您;)

标签: php json api twitter


【解决方案1】:
<?php
$json = file_get_contents("http://twitter.com/status/user_timeline/tareq_cse.json?count=10", true);
$decode = json_decode($json, true);

echo "<pre>";
$count = count($decode); //counting the number of status
for($i=0;$i<$count;$i++){
echo $decode[$i]['text']."<br>"; // in the original code there was $decode[$i][text] which is not correct
}
echo "</pre>";
?>

您必须将第 8 行的 text 索引放入 qoutes。我在这里发布了更正的版本。

该站点上的最后一个代码示例块在其所有行中也都有相同的错误。您必须将字符串数组索引放在引号中以避免引起注意。

【讨论】:

  • 谢谢伙计,你认为我可以通过这样做获得推文吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-12-30
  • 2011-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-07
相关资源
最近更新 更多