duanqun9618 2012-09-04 11:34
浏览 60
已采纳

微博oauth认证

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);
  • 写回答

2条回答 默认 最新

  • douyan2821 2012-10-19 09:50
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。