I'm using this for creating twitter follow buttons on my twitter web-app. Implementation is as easy as this:
<span id="follow-twitterapi"></span>
<script type="text/javascript">
twttr.anywhere(function (T) {
T('#follow-twitterapi').followButton("twitterapi");
});
</script>
when you put that code into your html document you get this button in that span element in an iframe:
after you click follow, you get this (or a similar thing saying you're following @someone):
however i can't get any information back to my app after this button is used, (because this is rendered in an iframe and because of same-origin policy of javascript, i can't access to contents of that iframe), is there any methods provided with this widget, to inform my app when a user starts following someone using this?
Thanks.
Go to https://publish.twitter.com/. Customize the follow button to your liking with the available options. Copy and paste the code into the HTML of your website wherever you would like the button to appear. (At this time, the follow button cannot be added to Facebook profiles.)
Twitter also hasn't changed the new colors for the Follow button, which has caused quite the confusion: The button is now filled in with black for accounts you've yet to follow and shows up with a white background for accounts you're already following. It used to be the other way around.
The Follow button is a small button displayed on your websites to help users easily follow a Twitter account. A Follow button consists of two parts: a link to a follow web intent page on Twitter.com and the Twitter for Websites JavaScript to transform the link into our recognizable Follow button.
To enable this feature, go to My Sites → Tools → Marketing and click on the Connections tab. Then, click the Connect button next to Twitter. You'll be taken to Twitter where you'll be asked to approve the connection between your WordPress.com site and your Twitter account. Click Allow.
You can. Here is my code:
<a href="https://twitter.com/gafitescu" class="twitter-follow-button">Follow @gafitescu</a>
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<script type="text/javascript">
twttr.events.bind('follow', function(event) {
console.log(event);
var followed_user_id = event.data.user_id;
var followed_screen_name = event.data.screen_name;
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With