Getting status (followed) of follow button on load with javascript?


#1

I need to get the status of a twitter “follow” button on load, not on click.

I’m currently loading the button via ajax, and call twttr.widgets.load() to get the widjet.js to do it’s magic.

I am aware of binding “follow” and “unfollow” to accept the callbacks from clicking the buttons, but how do I detect the current state of the button before any user interaction?

For instance, the page loads and the user is signed into twitter and currently following the target of the follow button, so it appears that they’ve already followed the user.

How do I detect this with javascript/jquery? I am not authorizing them through twitter at this point, so I can’t check via their api.

Other attempts:
I’ve also tried getting the contents of the iframe via javascript, since the twitter follow button iframe has a class specifying the state of the button, but it doesn’t seem to be possible due to CORS.


#2

#3