复制代码 代码如下:
stdClass Object
(
[data] =>
[detailerrinfo] => stdClass Object
(
[accesstoken] =>
[apiname] =>
[appkey] => 801485800
[clientip] => 112.193.138.133
[cmd] => 0
[proctime] => 0
[ret1] => 3
[ret2] => 3
[ret3] => 102
[ret4] => 3659629834
[timestamp] => 1394436892
)
[errcode] => 102
[msg] => missing parameter
[ret] => 3
[seqid] => 1394436894
)
在腾讯微博开放平台的官方资料中,未发现解释此错误代码102的开发文档,经过与腾讯微博PHP SDK对比后发现少了一个参数.
解决错误代码102的办法:
在请求用户资料的参数中oauth_version是必填的,而且在OAuth2中,它的值必须为2.a.
请求的参数中,OAuth2部分需包含:
字段 说明oauth_consumer_key appkey
access_token 授权获得的accesstoken
openid 授权获取的openid
clientip 客户端的ip
oauth_version 版本号,必须为2.a
scope 请求权限范围(默认“all”)
Drupal 腾讯微博登录实例代码:
复制代码 代码如下:
$http = drupal_http_request(url('https://open.t.qq.com/api/user/info', array(
'query' => array(
'access_token' => $access_token,
'oauth_consumer_key' => $provider['key'],
'openid' => $_GET['openid'],
'clientip' => ip_address(),
'scope' => 'all',
'seqid' => REQUEST_TIME,
'serverip' => $_SERVER['SERVER_ADDR'],
'oauth_version' => '2.a',
//'appfrom' => 'php-sdk2.0beta',
),
)));
注意:加上字段后需要重新从登录页面重新授权一次,不然会出现错误“check sign error” 错误代码36.
以下重复刷新接口导致的签名错误返回值,代码如下:
复制代码 代码如下:
stdClass Object
(
[data] =>
[detailerrinfo] => stdClass Object
(
[accesstoken] =>
[apiname] => weibo.user.info
[appkey] => 801485800
[clientip] => 112.193.138.133
[cmd] => 0
[proctime] => 0
[ret1] => 3
[ret2] => 3
[ret3] => 36
[ret4] => 2636350730
[timestamp] => 1394437225
)
[errcode] => 36
[msg] => check sign error
[ret] => 3
[seqid] => 1394437227
)
获取腾讯微博用户资料,获取当前登录用户的个人资料 user/info 接口返回值的字段说明,代码如下:
复制代码 代码如下: