0

在我的网站上,我的 Twitter 帐户和我的 Instagram 帐户有社交订阅源。我不知道该怎么做是在一个提要中按时间顺序显示它们(有点像时间线)

这是获取我的 twitter 提要的代码:

var cb = 新 Codebird;

var count = 5;

cb.setConsumerKey('2LafxW5AoTnUiNczNruSQ', 'yebQQOrk2FTYyI6tunIEEIJaPuLlauX52Pg26Gp4');
cb.setToken('1603894904-XLThNE8aodIWLfZ9QM19DaVlVDXdkBHkEPDthyO', 'By3nJ9BuMAyyzouxXLJEi9rZPoy1bYPSLvSZFKq3o');

function GetLinks(text) {
    text = text.replace(/(https?:\/\/\S+)/gi, function (s) {
        return '<a href="' + s + '">' + s + '</a>';
    });
    text = text.replace(/(^|)@(\w+)/gi, function (s) {
        return '<a href="http://twitter.com/' + s.replace(/@/,'') + '">' + s + '</a>';
    });
    text = text.replace(/(^|)#(\w+)/gi, function (s) {
        return '<a href="https://twitter.com/search?q=' + s.replace(/#/,'%23') + '">' + s + '</a>';
    });
    return text;
}

function GetTime(dateString) {

    var RightNow = new Date();
    var Then = new Date(dateString);
    var Difference = RightNow - Then;
    var Second = 1000, Minute = Second * 60, Hour = Minute * 60, Day = Hour * 24, Week = Day * 7;

    if (isNaN(Difference) || Difference < 0) {
        return "";
    }

    if (Difference < Second * 2) {
        return "right now";
    }

    if (Difference < Minute) {
        return Math.floor(Difference / Second) + " seconds ago";
    }

    if (Difference < Minute * 2) {
        return "about 1 minute ago";
    }

    if (Difference < Hour) {
        return Math.floor(Difference / Minute) + " minutes ago";
    }

    if (Difference < Hour * 2) {
        return "about 1 hour ago";
    }

    if (Difference < Day) {
        return Math.floor(Difference / Hour) + " hours ago";
    }

    if (Difference > Day && Difference < Day * 2) {
        return "yesterday";
    }

    if (Difference < Day * 365) {
        return Math.floor(Difference / Day) + " days ago";
    }

    else {
        return "over a year ago";
    }
}


cb.__call('statuses_userTimeline', {},

    function (tweets) {

        for (var i = 0; i < count; i++) {

        $('.tweets').append('<li class="tweet"><h3>tweet</h3><br /><i class="icon-twitter feed-icon"></i><div class="tweet_divider"></div><p class="tweet-text">' + GetLinks(tweets[i].text) + '</p><a class="tweet-time" href="http://twitter.com/' + tweets[i].user.screen_name + '/statuses/' + tweets[i].id_str + '">' + GetTime(tweets[i].created_at) + '</a><div class="spacer50"></div></li>');

        }
    }
);

对于我的 Instagram 提要:

$(function() {
$.ajax({
    type: "GET",
    dataType: "jsonp",
    cache: false,
    url: "https://api.instagram.com/v1/users/510044531/media/recent/?access_token=510044531.dbdf974.79feeaa3c20648a58b277aa31986f3b5",
    success: function(data) {
        for (var i = 0; i < 10; i++) {
    $(".instagram").append("<div class='instagram-placeholder'><a target='_blank' href='" + data.data[i].link +"'><img class='instagram-image' src='" + data.data[i].images.low_resolution.url +"' /></a></div>");   
        }     

    }
});

});

谁能建议我如何将这两者合并在一起?

4

0 回答 0