Php TwitterOAuth-无法验证oauth签名和令牌
我正在尝试用Twitter OAuth制作PHP应用程序。在我的代码中,我使用了库。我试图像库教程中那样进行授权,但当我尝试生成请求令牌时,出现以下错误: 致命错误:未捕获异常“Abraham\TwitterOAuth\TwitterOAuthException”,在/home/kp/domains/konradprzydzial.pl/public_html/tweetupchat/vendor/Abraham/TwitterOAuth/src/TwitterOAuth.php:221堆栈跟踪:#0/home/kp/domains/konradprzydzial.pl/public_html/tweetupchat/login.php(10):Abraham\TwitterOAuth\TwitterOAuth->oauth('oauth/request_t…',Array)#1{main}在第221行的/home/kp/domains/konradprzydzial.pl/public_html/tweetupchat/vendor/Abraham/TwitterOAuth/src/TwitterOAuth.php中抛出 我在此文件中的代码:Php TwitterOAuth-无法验证oauth签名和令牌,php,twitter,oauth,Php,Twitter,Oauth,我正在尝试用Twitter OAuth制作PHP应用程序。在我的代码中,我使用了库。我试图像库教程中那样进行授权,但当我尝试生成请求令牌时,出现以下错误: 致命错误:未捕获异常“Abraham\TwitterOAuth\TwitterOAuthException”,在/home/kp/domains/konradprzydzial.pl/public_html/tweetupchat/vendor/Abraham/TwitterOAuth/src/TwitterOAuth.php:221堆栈跟踪
<?php
require "vendor/autoload.php";
require "config.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
var_dump($request_token['oauth_token']);
var_dump($request_token['oauth_token_secret']);
$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
echo '<a href="'.$url.'">Zaloguj się</a>';
?>
消费者密钥和消费者密钥是正确的。问题出在哪里?我还在twitter API中使用abraham/twitteroauth包装器,遇到了同样的问题 这里的代码看起来不错。但是,如果您使用的是abraham在上提供的文档,那么一种解决方案是删除
CONSUMER\u键
和CONSUMER\u SECRET
周围的getenv()
函数
我只能猜测,因为我不知道config.php文件中使用的代码,但我希望这能有所帮助。我认为这是CURL的问题 尝试检查它们是否传递了正确的参数 abraham\twitteroauth\src\twitteroauth.php,第348行
您是否在对象实例化之前转储了消费者值,只是为了再次检查它们是否正确?另外,计算机的系统时钟设置是否正确?如果您的>~5分钟不同步,Twitter将失败。我已将其转储,它是正确的。我使用共享主机。服务器时间比Twitter API状态的时间提前2分钟。
function request($url, $method, $headers, $postfields)