duannan4486 2013-05-18 13:48
浏览 108
已采纳

如何使用Twitter API仅针对每个请求获取新推文?

I'm trying to get new tweets containing some hashtag from Twitter API. The thing I'm interested in is the number of new tweets each time I request the results. So like this:

10:20 AM: 100 tweets containing #google 
10:22 AM: 130 tweets containing #google

But right now somehow my results stay the same. This is my code:

PHP (tweets.php):

<?php 

$json = file_get_contents('http://search.twitter.com/search.json?q=%23apple:)&include_entities=true&rpp=100', true);
echo $json;
?> 

Javascript:

function getTweets() {
    var tweets = 0;
    $.ajax({
        url: "tweets.php",
        crossDomain: true,
        dataType: 'JSON'
        }).done(function(data) {
            $.each( data.results, function( key, value ) {
                console.log(value.entities);
                tweets++;

            });

    });
}
$(document).ready(function() {

    setInterval("getTweets()", 5000);

});

How can I get only the updates?

EDIT: My code works, but the results are not really updates. They are just the same results over and over again.

  • 写回答

2条回答 默认 最新

  • duanjie3267 2013-05-18 13:50
    关注
    $(document).ready(function() {
    
        setInterval(function(){ getTweets();}, 5000);
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂