Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a callback option with twitter's "follow button" widget

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:

alt text

after you click follow, you get this (or a similar thing saying you're following @someone):

alt text

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.

like image 694
Sinan Avatar asked Nov 30 '10 00:11

Sinan


People also ask

How do you get a Twitter follow link?

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.)

What is a black Follow button on Twitter?

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.

What does the follow button on Twitter look like?

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.

How do I add a Twitter follow button to WordPress?

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.


1 Answers

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>
like image 196
Gafitescu Daniel Avatar answered Oct 24 '22 16:10

Gafitescu Daniel