Reputation: 1650
I used weibo oauth api in magento for connect user with weibo.
But now weibo is broken and it completely get token but display error when we retrieve user data using authentication token.error is as follows..
i am using this code the use can successfully login but after that there is an error like this
[error_code] => 401
[error] => 40109:consumer_key_refused!
my code is here for after login\
$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);
Upvotes: 0
Views: 2762
Reputation: 1650
I found weibo new oauth2.0 authentication api that solve my problem.Use this if any one have problem in weibo user authentication..
Weibo-Oauth2 and follow Application scenarios step.
For get access token,you need to use form POST method instead of GET.so you use this code.
$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);
And use this url to get authenticate user data..
$userinfo = file_get_contents("https://api.weibo.com/2/users/show.json?access_token=".$access_token."&uid=".$userid);
$decoded_userinfo = json_decode($userinfo, true);
Hope this help to anyone..
Upvotes: 2