我使用magento中的微博oauth api来连接用户和微博。
但是现在微博坏了,它完全得到了令牌,但是当我们使用身份验证token.error检索用户数据时,显示错误如下。
我正在使用这个代码,用户可以成功登录,但之后会出现如下错误
[error_code] => 401
[error] => 40109:consumer_key_refused!我的代码在这里,用于登录后\
$c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] );
$ms = $c->home_timeline();
$me = $c->verify_credentials();
$ms = $c->show_user($userid);发布于 2012-10-19 17:50:58
我找到了微博新的oauth2.0认证api,它解决了我的problem.Use,如果有人在微博用户认证方面有问题的话..
Weibo-Oauth2和遵循应用场景步骤。
对于get访问令牌,您需要使用表单POST方法,而不是使用以下代码的GET.so。
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Content-Type: text/xml\r\n"
)
);
$context = stream_context_create($opts);
$uri= 'https://api.weibo.com/oauth2/access_token?client_id='.WB_AKEY.'&client_secret='.WB_SKEY.'&grant_type=authorization_code&redirect_uri='.YOUR_REGISTERED_REDIRECT_URI.'&code='your authorization code;
$authkey1 = file_get_contents($uri,false,$context);
$decoded_auth1 = json_decode($authkey1,true);并使用此url获取经过身份验证的用户数据..
$userinfo = file_get_contents("https://api.weibo.com/2/users/show.json?access_token=".$access_token."&uid=".$userid);
$decoded_userinfo = json_decode($userinfo, true);希望这对任何人都有帮助..
发布于 2012-09-20 17:10:57
在oauth2中使用weibo_2。请。
https://stackoverflow.com/questions/12262650
复制相似问题