首先需要进行鉴权操作admin管理员组文章数量:1392014
一.鉴权操作过程:
第1步:请求code
网址:https://open.t.qq/cgi-bin/oauth2/authorize
方式:GET
参数:应用ID, 回调网址
返回:用户登录并跳转回调网址, code、openid、openkey
实例:
请求:https://open.t.qq/cgi-bin/oauth2/authorize?client_id=xxx&response_type=code&redirect_uri=http://www.test_2012_12_12
返回:http://www.test_2012_12_12/?code=xxx&openid=xxx&openkey=xxx
第2步:请求accesstoken
网址:https://open.t.qq/cgi-bin/oauth2/access_token
方式:GET
参数:code、应用密码、第一步操作返回的其它参数
返回:access_token
实例:
请求:https://open.t.qq/cgi-bin/oauth2/access_token?client_id=xxx&client_secret=xxx&redirect_uri=http://www.test_2012_12_12&grant_type=authorization_code&code=xxx
返回:access_token=xxx&expires_in=604800&name=xxx
二.鉴权操作后就可以直接调用API, API一般可以返回XML或JSON数据,一般都要带上鉴权信息, 大多数操作只支持POST:
实例:
取用户信息:
请求:https://open.t.qq/api/user/info?oauth_consumer_key=xxx&access_token=xxx&openid=xxx&clientip=127.0.0.1&oauth_version=2.a&scope=all
返回:{"data":{"birth_day":21,"birth_month":4,"birth_year":1987,"city_code":"1" ...},"errcode":0,"msg":"ok","ret":0}
发布, 只支持POST方式:
请求:https://open.t.qq/api/t/add/format=json&content=test&oauth_consumer_key=xxx&access_token=xxx&openid=xxx&clientip=127.0.01&oauth_version=2.a&scope=all
返回:{"data":{"id":"xxx","time":xxx},"errcode":0,"msg":"ok","ret":0}
本文标签: 腾讯
版权声明:本文标题:腾讯微博 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1737854421a2027151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论