1

我在我的网站上使用此代码已经有一段时间了,现在它停止工作了?

我知道这与现在更新的 API 版本有关,但需要知道修复此脚本需要什么?

代码最初来自: http ://www.queness.com/code-snippet/6495/get-the-latest-twitter-tweet-with-jquery

$(function() {

// set your twitter id
var user = 'quenesswebblog';

// using jquery built in get json method with twitter api, return only one result
$.getJSON('http://twitter.com/statuses/user_timeline.json?screen_name=' + user + '&count=1&callback=?', function(data)      {

    // result returned
    var tweet = data[0].text;

    // process links and reply
    tweet = tweet.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
        return '<a href="'+url+'">'+url+'</a>';
    }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
        return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
    });

    // output the result
    $("#tweet").html(tweet);
}); 

});

谢谢,

TJ。

4

1 回答 1

1

来自 Twitter 总部的坏消息是 url 现在返回http://twitter.com/statuses/user_timeline.json?screen_name=xxx现在只返回“抱歉,该页面不存在”,从 2012 年 10 月 12 日开始。

您将需要使用https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=xxx&count=2并修改您的剩余代码,但我相信这将在 2013 年 3 月和您将需要使用 oAuth 进行验证。

高温高压

于 2012-10-16T13:26:18.063 回答