开发者

Twitter JSON Request Parsing Error

I'm using the following code to get a JSON string that I'm going to parse into a table of Twitter statuses.

var fileref = document.createElement('script');
fileref.setAttribute("type","text/json");
fileref.setAttribute("src", "http://search.twitter.com/search.json?q=centrikidcamps&callback=TweetTick&rpp=10");

The callback parses them and sets them up - at least it has for the past couple of days. But now I get inconsistent return values. Specifically, sometimes I get TweetTick({"results":[ ... ) which is what I want. And s开发者_运维技巧ometimes I get {"completed_in ... which results in a parse error. I got this code snippet from the site below (I'm providing this for credit and as a demo example). Is this a transient Twitter thing? Should I be doing things differently to prevent this? Thanks!

http://tutorialzine.com/2009/10/jquery-twitter-ticker/


<script>
$(function(){
    $.getJSON('http://search.twitter.com/?q=centrikidcampsrpp=10&callback=?',
        function(data){
            var responseObject = data;
        }
});
</script>

it will work few times and sometimes not weird. it looks first response of

http://search.twitter.com/search.json?q=Twitter%20API&result_type=mixed&count=5&callback=resx

starts with:

resx({"results":[{"from_user_id_str":"291792770","profile_image_url":"http://a2.twimg.com/profile_images/1442845316/yo_pjj_normal.jpg","created_at":"Fri, 15 Jul 2011 00:42:04 ......

and next time it starts with

{"completed_in":0.041,"max_id":91667423308156928,"max_id_str":"91667423308156928","next_page":"?page=2&max_id=91667423308156928&q=Twitter%20API","page":1,"query":"Twitter+API","refresh_url":"?since_id=91667423308156928&q=Twitter%20API","results":[{"created_at":"F

it's their problem...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜