Search code examples
javascriptfacebookfacebook-graph-apifacebook-access-token

Use Facebook Graph API to search for users


I'm working on application and I want to connect it to facebook. The user should type his (name/username) in a textbox and automatically my app should find his account of facebook. In order to search for users I need user access token. How can I get a user access token before my user enter his username and password? I'm using Javascript SDK.


Solution

  • I think what you want is possible with server side authentication (OAuth).

    Once logged in via OAuth, you have an access token (not from the user, but from your own account or the account of your page). With that access token, you're able to search for the person's name, e.g. https://graph.facebook.com/search?q=mark&20zuckerberg&type=user. However, you can't be sure which account is from the user if there are multiple query results.