【问题标题】:php twitteroauth from Abraham error code 32 at getting aouth url for user authenticating来自 Abraham 的 php twitteroauth 在获取用户身份验证的 aouth url 时出现错误代码 32
【发布时间】:2018-02-27 18:18:08
【问题描述】:

我想获取用户身份验证访问令牌来访问他的个人资料信息。当我运行脚本时,它抛出了以下错误

致命错误:未捕获的异常 'Abraham\TwitterOAuth\TwitterOAuthException' 带有消息 '{"errors":[{"code":32,"message":"Could not authenticate you."}]}' 在 C:\xampp\htdocs\promo\app\twitteroauth\src\TwitterOAuth.php:138

我的代码是

 $twitteroauth = new TwitterOAuth($config['consumer_key'], 
 $config['consumer_secret']); 
 //request token of application
 $request_token = $twitteroauth->oauth(
    'oauth/request_token', [
'oauth_callback' => $config['url_callback']
    ]
 );
 // throw exception if something gone wrong
 if ($twitteroauth->getLastHttpCode() != 200) {
 throw new \Exception('There was a problem performing this request');
 }
 // save token of application to session
 $_SESSION['oauth_token'] = $request_token['oauth_token'];
 $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
 // generate the URL to make request to authorize our application
 $url = $twitteroauth->url(
    'oauth/authorize', [
'oauth_token' => $request_token['oauth_token']
    ]
 );
 // and redirect
 header('Location: ' . $url);

请告诉我如何解决该错误。根据我的发现,当以下函数通过上述异常调用它时。

// request token of application
$request_token = $twitteroauth->oauth(
    'oauth/request_token', [
'oauth_callback' => $config['url_callback']
    ]
 );

【问题讨论】:

    标签: php twitter-oauth


    【解决方案1】:

    我设置了 twitter 应用程序的重定向 url,这解决了我的代码 32 问题

    【讨论】:

      猜你喜欢
      • 2015-05-07
      • 1970-01-01
      • 2015-09-23
      • 2016-07-20
      • 2021-07-14
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 1970-01-01
      相关资源
      最近更新 更多