如何使用jquery添加转发和收藏按钮

How to add retweet and favorite buttons using jquery?

本文关键字:收藏 按钮 转发 添加 何使用 jquery      更新时间:2023-09-26

我在javascript/jquery中制作了一个代码,它用特定句柄的推文填充了一个部门。

$.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+ handle + "&count=" + noOfTweets + "&include_rts=true&callback=?", function(data) {
    //some code
});

这是显示推文的代码

Json.parse(data);
$.each(data, function(i, tweet) {
  var buttonString = '<br/><a onclick="retweet('+tweet.id+')">Retweet</a>'
                            +'<a onclick="favorite('+tweet.id+')">Favorite</a>';
  $("#tweets").append($("<li/>").html(tweet.text+" <span class='tweetTime'>--a moment ago.</span>")+buttonString);
}

我现在想在推文中添加转发和收藏按钮。上述函数的 twitter api 需要一个 post 请求,但 jquery 没有任何 .postJSON(( 函数https://dev.twitter.com/docs/api/1/post/statuses/retweet/:id和https://dev.twitter.com/docs/api/1/post/favorites/create/:id

那么我的转发和收藏夹函数应该包含什么?请帮忙。

jQuery有一个发出POST请求的函数 - jQuery.post((

改用网络意图。不可取,但还不错。