douba3378 2014-01-23 06:39
浏览 56

提取推文和存储

<?php
$mongo = new Mongo();
$db = $mongo->twitter;
$collection = $db->tweets;
$screen_name = "learnmongo";
$twitter = "http://api.twitter.com/1/statuses/user_timeline.json?";
$twitter .= "screen_name=" . $screen_name;
$curl = curl_init($twitter);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$usertimeline = curl_exec($curl);
curl_close($curl);
$usertimeline = json_decode($usertimeline);
foreach ($usertimeline as $id => $item) {
$collection->insert($item);
}

?>

execution of this code gives error message as invalid parameters to foreach().plzz reply and hep me to solve this problem

  • 写回答

1条回答 默认 最新

  • dtmbc1606 2014-01-23 07:05
    关注

    You are using a deprecated verion of the Twitter API. Version 1.0 no longer works, you need to use version 1.1. You need to use version 1.1 of the call. The API URL has changed from:

    http://api.twitter.com/1/statuses/user_timeline.json
    

    to

    http://api.twitter.com/1.1/statuses/user_timeline.json
    

    Unfortunately the new 1.1 version requires authentication so your code will still not work until you implement an OAUTH solution for authentication.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!