0

ユーザーをweiboに接続するために、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);
4

2 に答える 2

2

私の問題を解決するweiboの新しいoauth2.0認証APIを見つけました.weiboユーザー認証に問題がある場合はこれを使用してください..

Weibo-Oauth2 を開き、アプリケーション シナリオの手順に従います。

アクセストークンを取得するには、GET ではなくフォーム POST メソッドを使用する必要があるため、このコードを使用します。

$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-10-19T09:50:57.800 に答える
0

oauth2で weibo_2 を使用します。お願いします。

于 2012-09-20T09:10:57.470 に答える