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.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集