简体   繁体   中英

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.

How can I get a user access token before my user enter his username and password?

Simple answer: You can't.

Why do you want the user to search for his own account anyways? Just have him log in, and you know immediately who he is (and so does he, most likely even before logging in).

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, eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM