人人网的文档写的真的和屎一样,根本就不用那么复杂
1.申请 APP key 和 secret key 网址:http://dev.renren.com/
2.点击网页上的按钮,跳转到
1
|
http: //graph.renren.com/oauth/authorize?response_type=code&client_id= your app key &redirect_uri=http%3A%2F%2Fwww.fengzi.net.cn%2Frecord%2Findex.php%3Fm%3Dmember%26c%3Dindex%26a%3Dpublic_snda_login%26callback%3D1
|
3.就是输入账号密码的页面,然后确定,就会到redirect_uri 你的回调的地址 并且GET过来的code 是一个 32 位的字符串 ,有效期一个小时
4.用curl 执行下面的网址
1
|
https: //graph.renren.com/oauth/token?&grant_type=authorization_code&code=返回的code&client_id=你的key&client_secret=你的密码&redirect_uri=http%3A%2F%2Fwww.fengzi.net.cn%2Frecord%2Findex.php%3Fm%3Dmember%26c%3Dindex%26a%3Dpublic_snda_login%26callback%3D1
|
5.返回的结果如下
1
|
{ "token_type" : "bearer" , "expires_in" :2594408, "refresh_token" : "268872|0.Bq1QVptzxvs9yWnUA7ICRE7sQMNNCzb1.820897483.1402042721194" , "user" :{ "id" :820897483, "name" : "林志玲" , "avatar" :[{ "type" : "avatar" , "url" : "http://head.xiaonei.com/photos/0/0/women_head.gif" },{ "type" : "tiny" , "url" : "http://head.xiaonei.com/photos/0/0/women_tiny.gif" },{ "type" : "main" , "url" : "http://head.xiaonei.com/photos/0/0/women_main.gif" },{ "type" : "large" , "url" : "http://head.xiaonei.com/photos/0/0/women_main.gif" }]}, "access_token" : "268872|6.b5d47f3ae3e2c1f99d14e5395b2b3551.2592000.1404637200-820897483" }
|
是一个json格式 转一下就可以成数组了
6.用唯一的东一 记录到数据库 执行登陆