微博oauth认证


weibo oauth authentication

我在magento中使用了weibo oauth api来连接用户和weibo。

但现在微博坏了,它完全得到了令牌,但显示错误当我们使用身份验证令牌检索用户数据时。错误如下。。

我正在使用这个代码,使用可以成功登录,但之后有一个类似的错误

[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);

我发现微博新的oauth2.0身份验证api解决了我的问题。如果有人在微博用户身份验证中遇到问题,请使用此选项。。

Weibo-Outh2并遵循应用程序场景步骤。

对于获取访问令牌,您需要使用表单POST方法而不是get。因此,您使用此代码。

$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);

希望这对任何人都有帮助。。

将weibo2与oauth2一起使用。请