steps for facebook connect graph api
iam using facebook connect in my site, and i want to know how do i use the graph api for authenticating the user. I followed these steps:
1) Initially i sent a request for "code", by clicking on the facebook icon in my site:
https://graph.facebook.com/oauth/authorize? client_id=xxx&redirect_uri=http://xxxxxxxx
2) And then after getting a code, i sent a request for "access token", by clicking on another link in my site:
https://graph.facebook.com/oauth/access_token? client_id=xxx&redirect_uri=http://xxxxxxx&client_secret=xxxx&code=xxxxx
3) And after i got the token, i sent another request for getting user data, by clicking on yet another link:
https://graph.faceb开发者_运维问答ook.com/me?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Then finally i got the user data in array format, which i need to parse for my required data like user's firstname, email, etc.
Now my question is that how i can automate this process with just one click ? Right now, iam using 3 different links for sending those requests.
Can anyone suggest a solution ?
If you want to skip these hassles, use Facebook JavaScript SDK. It provides all the core functionality for authenticating Facebook users. Load the JS SDK using your APP ID
by FB.init()
method. Then for user-login or extended permissions, you can use FB.Login()
and likewise. It will take care of all OAuth
communication, which you were doing by-hand. More information at
- http://developers.facebook.com/docs/authentication/javascript
- http://developers.facebook.com/docs/reference/javascript/
You can use the Facebook API for that: https://github.com/facebook/php-sdk/
Look at the example on that website for more information.
maybe quicker to use the official facebook implementation for php - you can find it here: https://github.com/facebook/php-sdk
精彩评论