doujin8673 2015-06-16 11:03
浏览 61

如何在速率限制超过后撤销Twitter API请求?

I am working with Twitter API 1.1 and I am fetching tweets of a user.

I am using this code

<?php
        $url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
        $requestMethod = "GET";
        $cursor = isset($cursor) ? $cursor : "-1";
        $getfield = "?cursor=" . $cursor . "&user_id=" . $user . "&count=10";
        $twitter = new TwitterAPIExchange($settings);               
        $string  = $twitter->setGetfield($getfield)
                ->buildOauth($url, $requestMethod)
                ->performRequest();
        $tweets = json_decode($string, 1); 
        echo '<pre>';print_r($string);echo '</pre>';
 ?>

Is there way to recieve since_id after a particualr request so that I can requeue my function for the next request starting from the last recieved id?

For Example: In a single request I am fetching 0-1000 records, On my next request I want start from 1001th record.

Is it possible in twitter?

  • 写回答

1条回答 默认 最新

  • duannaoye0732 2015-06-16 14:16
    关注

    If you made a request to a timeline without using since_id, and the most recent tweet you got back had the ID "123" then, after an interval, you can use that most recent tweet ID "123" as your since_id value to user_timeline. You would then get (up to 200) of the next most recent tweets posted by that user "since" they posted tweet "123".

    评论

报告相同问题?

悬赏问题

  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统