Twitter Tweet or ReTweet Callbacks

女生的网名这么多〃 提交于 2019-12-09 01:52:40

问题


Hope you are having a good time. I am creating a website where when users Tweet a wordpress blog entry then they get points on the websites.

So basically, if a user Tweets that entry on his Twitter then we would give him some points to use on the website (not money). Although this thing is plausible with Facebook but not with Twitter in my knowledge.

I am willing to try to both ways by Twitter Tweet Button or TweetMeme Retweet Facility. However, I could not find a facility for a callback at neither of these.

I am implementing a similar functionality in Facebook and I can see the light at the end of the tunnel with using FBML JS SDK. HOwever, if something similar can be achieved with Twitter then it would be awesome.

Would love to hear more from you guys,

Kind Regards,

Khuram


回答1:


They've fixed this with the intents function:

https://dev.twitter.com/pages/intents-events

twttr.events.bind('tweet', function(event) {
// Do something there
});

or for clicking

twttr.events.bind('click', function(event) {
var click_type = event.region;
});



回答2:


using Twitters @anywhere api, you can set an onTweet function that does something when someone tweets.

here is a 6-step tutorial, see number 4

A default tweetBox can be called after the element with the comments class with the following snippet.

twttr.anywhere(function(twitter) {
    twitter(".comments").tweetBox();
});

So if you want a custom label, content, and a callback when the tweet has been sent, use this code.

twitter(".comments").tweetBox({
    label: 'What do you think about this article?',
    defaultContent: '#nettuts ',
    onTweet: function(plain, html){
        // Actions when tweet is sent
    }
});



回答3:


opening tweet intent pop from JS code will send a callback. You need to put your tweet URL in herf of anchor tag

HTML:

<a target="_blank" href="https://twitter.com/intent/tweet?text=itismytext&url=http://google.com"> twitter share</a>

JavaScript:

$(document).ready(function(){

    twttr.events.bind('tweet', function(event) {
        console.log(event);
        // OR
        alert(JSON.stringify(event));
    });

});


来源:https://stackoverflow.com/questions/3600217/twitter-tweet-or-retweet-callbacks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!