Search code examples
facebookuserid

get the facebook user id in fan page using js


I use "html static iframe tab by woobox" to create a fan gate. The fan gate shows differnt pages for users who liked the page, and another page for non-likers. I have two aspx pages on my server one for likers and one for none-likers. For the likers page whitch has an Iframe I link my first webpage. In this webpage i want to get the facebook userid that is currently in the likers page.

Do I have to create an application in order to get the userid? Do i have to get the user permission? How do i use js sdk to do it? Thanks


Solution

  • Yes, you have to create an App to get the User ID, and the user must authorize your App. See here for further information about login with the JavaScript SDK: https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.0

    But keep in mind that you will NOT get the real User ID, Facebook made some changes recently and you can only get an "App Scoped ID" - see the Changelog for further information: https://developers.facebook.com/docs/apps/changelog

    Don´t worry, the App Scoped ID will not change, even if the User deauthorizes and authorizes your App again.