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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里