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/
不知道该不该放首页,惶恐的放一下吧,或许有人要用到也说不准呢。
虽然是一个不存在的网站,但也是工作内容的一部分,需要认真对待.既然对于咱们国人来说不存在,当然也就没有汉字可看了.英文文档让我头晕了好一阵子,吐了好几次之后终于摸清了脉络.
大致步骤是:
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/
不知道该不该放首页,惶恐的放一下吧,或许有人要用到也说不准呢。
相关文章推荐
- IOS中http请求数据的解析以及http状态码的获取
- fetch 请求数据 以及 node 后端 post请求获取不到数据的记录
- Java从网络中请求获取JSon数据以及解析JSON数据----(自创,请注明)
- Angularjs 数据请求和数据,以及获取地址栏信息提交service
- Android 判断应用程序获取通知栏权限是否开启,以及如何跳转到应用程序设置界面
- 表单中多个请求参数名字相同,服务器到底获取的是哪个请求参数的值,表单的action和get和post提交方式的关系以及提交数据的不同点
- java ajax 请求后获取 json 数据 以及 使用 解析 ,解惑
- Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer 关于Newtonsoft.Json,LINQ to JSON的一个小demo mysql循环插入数据、生成随机数及CONCAT函数 .NET记录-获取外网IP以及判断该IP是属于网通还是电信 Guid的生成和数据修整(去除空格和小写字符)
- 第十二篇:Android GET请求获取网络数据以及POST数据(使用HttpURLConnection)
- linux之用echo输入数据到文本末尾以及用open ssl命令在证书文件里面获取公钥
- 在vuex的store中如何正确的通过axios进行请求操作获取数据
- Play2.5获取POST请求提交的表单数据
- 网络编程_get_异步-请求_获取网络数据
- Gzip方式数据请求以及解码
- android通过httpClient请求获取JSON数据并且解析
- AJAX 跨域请求 - JSONP获取JSON数据
- 用JQuery Ajax 与一般处理程序 请求数据无刷新,以及如何调试错误
- 网络请求 获取数据
- [置顶] python语言处理get类型请求,调试模式获取数据代码
- SpringMVC请求转发与重定向以及视图与数据的返回