您的位置:首页 > 其它

web第三方登录接入

2015-07-31 11:48 453 查看
其实最麻烦的是在平台申请各种权限,申请地址

1、微博接入(open.weibo.com):

2、QQ接入(open.qq.com)

3、微信接入(open.weixin.qq.com)

QQ登录

1.授权登录
https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101228213&redirect_uri=http%3A%2F%2Fwww.xiuktv.com%2F&scope=get_user_info,do_like&state=709218
2.[server]通过Authorization Code获取Access Token
https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=101228213&client_secret=a8a287******f22ef38b7ce&code=272BFAD7BF8C8B30A589D3EA7426CF2D&state=709218&redirect_uri=http://www.xiuktv.com
access_token=473493337F45033713956ED5D05D149D&expires_in=7776000&refresh_token=1750213580EC593D5340AACF7CEB7E56

3.[server](可选)权限自动续期,获取Access Token
https://graph.qq.com/oauth2.0/token?grant_type=refresh_token&client_id=101228213&client_secret=a8a287******f22ef38b7ce&refresh_token=1750213580EC593D5340AACF7CEB7E56
access_token=3CA1F11C13B8C44931262654B19A0ECD&expires_in=7776000&refresh_token=1750213580EC593D5340AACF7CEB7E56

4. 获取到用户OpenID
https://graph.qq.com/oauth2.0/me?access_token=6E67763A4B00EF1350C367EAB420FEC5
callback( {"client_id":"101228213","openid":"0D8750B0136B77B714C7669BD4F99040"} );

5.get_user_info
https://graph.qq.com/user/get_user_info?access_token=6E67763A4B00EF1350C367EAB420FEC5&oauth_consumer_key=101228213&openid=0D8750B0136B77B714C7669BD4F99040
{ "ret": 0, "msg": "", "is_lost":0, "nickname": "お父さん", "gender": "男", "province": "北京", "city": "东城", "year": "1965", 

"figureurl": "http:\/\/qzapp.qlogo.cn\/qzapp\/101228213\/0D8750B0136B77B714C7669BD4F99040\/30", 

"figureurl_1": "http:\/\/qzapp.qlogo.cn\/qzapp\/101228213\/0D8750B0136B77B714C7669BD4F99040\/50", 

"figureurl_2": "http:\/\/qzapp.qlogo.cn\/qzapp\/101228213\/0D8750B0136B77B714C7669BD4F99040\/100", 

"figureurl_qq_1": "http:\/\/q.qlogo.cn\/qqapp\/101228213\/0D8750B0136B77B714C7669BD4F99040\/40", 

"figureurl_qq_2": "http:\/\/q.qlogo.cn\/qqapp\/101228213\/0D8750B0136B77B714C7669BD4F99040\/100", 

"is_yellow_vip": "0", "vip": "0", "yellow_vip_level": "0", "level": "0", "is_yellow_year_vip": "0" }

{"uid":0,"headimg100":"http://q.qlogo.cn/qqapp/101228213/0D8750B0136B77B714C7669BD4F99040/100","nickname":"お父さん","openid":"0D8750B0136B77B714C7669BD4F99040","headimg40":"http://q.qlogo.cn/qqapp/101228213/0D8750B0136B77B714C7669BD4F99040/40","success":true}

微博登录

1.授权登录
https://api.weibo.com/oauth2/authorize?client_id=2571723605&redirect_uri=http://www.xiuktv.com&response_type=code&state=12345 http://www.xiuktv.com/?code=6ebd197bd93c1ccd817836b74357a268
2.获取 token
https://api.weibo.com/oauth2/access_token?client_id=2571723605&client_secret=94eb336******aac8d7d540&grant_type=authorization_code&code=976247f3f7f2ec50192d0c55b774e739&redirect_uri=http://www.xiuktv.com
state=12345&code=976247f3f7f2ec50192d0c55b774e739

{"access_token":"2.00tWPUFCzmgCoCb293f27c39w5Z8kD","remind_in":"157679999","expires_in":157679999,"uid":"1913356883"}

3.
https://api.weibo.com/oauth2/get_token_info?access_token=2.00tWPUFCzmgCoCb293f27c39w5Z8kD
{"uid":1913356883,"appkey":"2571723605","scope":null,"create_at":1436420674,"expire_in":157679872}

4.获取用户信息
https://api.weibo.com/2/users/show.json?access_token=2.00tWPUFCzmgCoCb293f27c39w5Z8kD&uid=1913356883
微信登录
https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect
[{uid=o1XQvuMUgWYFwq8Toj1Z-I9Zy5Y8, refresh_token_expires=604800, scope=snsapi_userinfo, unionid=oJCHPv0y65qE3Shb8BE3HuFcxhCU, 

expires_in=7200, openid=o1XQvuMUgWYFwq8Toj1Z-I9Zy5Y8, refresh_token=OezXcEiiBSKSxW0eoylIeEZ6TjjzCFYe81Mo8wfPyWPIMDLjLroUsah6Nlvo33F6iwYvufy2IlhpTBL0E8pQ6R3brigv7fCAhnhpVgzjc0vyiCpJqUa1nnqWxXa93EtMjq1Sffhc8SErirQoANFJQA, 

access_token=OezXcEiiBSKSxW0eoylIeEZ6TjjzCFYe81Mo8wfPyWPIMDLjLroUsah6Nlvo33F6hIwU_sU8heLmxrtwHpbD8LFJIzoql07bQ-yXlkJlKwNlSzqT9XGeKZ1VAGg4iiwGLubV3rxmEWxlLD8xCyZ5AA}]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: