您的位置:首页 > 其它

Facebook应用程序权限请求以及数据获取

2011-11-15 18:14 183 查看
最近因工作需要研究了一下facebook的API调用.

虽然是一个不存在的网站,但也是工作内容的一部分,需要认真对待.既然对于咱们国人来说不存在,当然也就没有汉字可看了.英文文档让我头晕了好一阵子,吐了好几次之后终于摸清了脉络.

大致步骤是:

1、创建一个应用程序,可以获得App ID/API Key和App Secret。

2、使用URL:

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream

其中YOUR_APP_ID就是你的APPID, YOUR_URL就是你应用程序的URL,Canvas程序就填Canvas的URI, scope就是请求的权限.

这个界面进去就是跟国内的微博应用一样了,是一个申请用户授权的页面,用户点击授权后,facebook会这样请求你的YOUR_URL:

http://your_url/?code=A_CODE_GENERATED_BY_SERVER

你的URL会收到一大串加密字符的Get请求.

3、拿出这一大串密钥,通过下面的URI获取到access_token

https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE

最后的code 就是第二步获取到的code了.请求这个URI会得到access_token,拿到这个之后,就可以在任何地方做你想做的事啦.

4、各种API:

Friends: https://graph.facebook.com/me/friends?access_token=...
News feed: https://graph.facebook.com/me/home?access_token=...
Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
Likes: https://graph.facebook.com/me/likes?access_token=...
Movies: https://graph.facebook.com/me/movies?access_token=...
Music: https://graph.facebook.com/me/music?access_token=...
Books: https://graph.facebook.com/me/books?access_token=...
Notes: https://graph.facebook.com/me/notes?access_token=...
Permissions: https://graph.facebook.com/me/permissions?access_token=...
Photo Tags: https://graph.facebook.com/me/photos?access_token=...
Photo Albums: https://graph.facebook.com/me/albums?access_token=...
Video Tags: https://graph.facebook.com/me/videos?access_token=...
Video Uploads: https://graph.facebook.com/me/videos/uploaded?access_token=...
Events: https://graph.facebook.com/me/events?access_token=...
Groups: https://graph.facebook.com/me/groups?access_token=...
Checkins: https://graph.facebook.com/me/checkins?access_token=...

API手册:https://developers.facebook.com/docs/reference/api/

不知道该不该放首页,惶恐的放一下吧,或许有人要用到也说不准呢。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐