How do you check if a user is following you using PHP, JS and / or REST API?

I just need to know if someone is following me on Twitter when they load my site.

I have the following button hosted on my website so that users can easily follow me (I made a button through http://twitter.com/about/resources/buttons#follow )

I think the problem is that if they have not logged in to Twitter and they press a button to follow, it will ask for a username / password. Is there any way to check if they are logged in? I assume there is some oauth cookie value? However, since I use the twitter follow button, does this persist somewhere?

Then, after I confirm that they are logged in, I see that there is "friendship / exists", but for this you need to know that the user is user_id or screen_name, which goes back to the question above regarding authentication.

I assume that I will have a “check” button next to the Twitter button that forces the user to log back in and create a local session variable so that I can process this and check if they are following me. Am I taking the right approach? Or is it too complicated?

+5
source share
1 answer

. API @ . , API cookie , .

: https://dev.twitter.com/discussions/3238

API

https://api.twitter.com/1/followers/ids.json?screen_name=twitterapi

https://dev.twitter.com/docs/api/1/get/followers/ids

https://api.twitter.com/1/friends/ids.json?screen_name=twitterapi

https://dev.twitter.com/docs/api/1/get/friends/ids

+1

All Articles