How do i get some javascript to run whenever a follow button is clicked in the twitter API? I'开发者_如何学Cm new to the twitter API, i know in Facebook its a event subscribe, so whats the equivalent?
You can use below code. You will get
FOLLOW!
alert after clicking on follow button
<html>
<a href=http://twitter.com/directdialogs class="twitter-follow-button"
data-show-count="true">Follow@directdialogs</a>
<script type="text/javascript" charset="utf-8">
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
js.src="//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
</script>
<script>
twttr.ready(function (twttr) {
twttr.events.bind('follow', function(e) {
alert("FOLLOW!")
});
});
</script>
</html>
精彩评论