I simply need to know if someone is following me on twitter, when they load my website.
I have a follow button posted on my website for users to follow me easily (I made the button via: http://twitter.com/about/resources/buttons#follow)
I guess the issue is this--if they aren't logged into twitter, and they click the button to follow, it will prompt for a username/password. Is there a way to verify if they are already logged in? I assume there's some sort of oauth cookie value? However, since I'm using twitter's follow button, is this saved somewhere?
Then, after I verify that they are logged in, I see that there is "friendships/exists" but this would require to know what the person's user_id or screen_name, which goes back to the question above concerning authentication.
My guess is that I will have to have a "verify" button next to twitter's follow button, which would force the user to log in again and create a local session variable so I can process that and verify if they are following me. Am I taking the right approach in doing so? Or is that too complicated?
You have made a step in the right direction. You would use Twitter's @anywhere API for this. If the user authenticates your website, the API will drop a cookie on your site determining the connected state of the user.
You may want to also check out this post: https://dev.twitter.com/discussions/3238
The relevant API call would be,
your followers
https://api.twitter.com/1/followers/ids.json?screen_name=twitterapi
https://dev.twitter.com/docs/api/1/get/followers/ids
your following
https://api.twitter.com/1/friends/ids.json?screen_name=twitterapi
https://dev.twitter.com/docs/api/1/get/friends/ids
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