My website application having feature login with Facebook login. And for which my app is present on Facebook. Login with facebook is working fine.
But application have feature of linking and unlinking facebook account to Facebook app.
- How to check FB account is linked with specific FB app or not?
- And how to unlink FB account from specific FB app if linked (On that user's request )?
("Linked" means we select "Allow" to FB app on request)
This can easily achieved with simple FQL query:
This will return uid of user if he is connected with app and nothing otherwise
Through the Graph API, from the docs (thanks @DMCS):
The olds REST API offers you
auth.revokeAuthorization
. You can read more about that on the auth.revokeAuthorization docs.Be aware that the REST API will be deprecated in the future, although Facebook doesn't specify when exactly.
I am not aware of any way to get a list of apps a given user is connected to, or see any reason Facebook would make that available. To see if a user is connected to your app, the other answers here should provide you with a couple of ideas.
Here's how to deauthorize your app using Facebook iOS SDK v4:
With the new Graph there is a documented way to deauthorize (I've tested it in the Graph API explorer and it works). Send an HTTP Delete command to "me/permissions" with a valid access token. Not only will it invalidate the access token, but it also removes the app from the user's list of auth apps. This requires the user to authorize the app again (going thru the permissions screens) to use it. Happy coding!
Please note Facebook in the process of deprecating the REST API, and have adding equivalent support to the Graph API User object for "auth.revokeAuthorization" method.
Make an API call to
/{USER_ID}/permissions
with your App access token and it will show if that user has authorised your appYou can also check with the user's access token if you have one.
The response type will be something like this:
There'll be one entry there for each extended permission the user has granted your app and the
installed
line means they've installed your appFor a user who hasn't installed your app the response will be:
You can also use FQL as Juicy Scripter suggests in another answer