Twitter和Oauth导致401错误
问题描述:
我使用Oauth连接到Twitter,但会导致401错误。我在这里做错了什么?Twitter和Oauth导致401错误
//config
define('CONSUMER_KEY',"");
define('CONSUMER_SECRET',"");
define('OAUTH_TOKEN',"1U");
define('OAUTH_TOKEN_SECRET',"");
require_once('twitteroauth/twitteroauth.php');
$connection = new TwitterOAuth (CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
$connection->post('statuses/update', array('status' => 'testing'));
$httpc = $connection->http_code;
if($httpc == 200) {
echo 'succesvol';
} else {
echo $httpc;
}
答
你得到一个401 (Not Authorised)
错误时,你不提供正确的ConsumerKey
和ConsumerSecret
值。
看看上面的代码,您传递这两个变量的空字符串值。除非你故意留下,否则你需要仔细检查你的值。
对于我的应用程序,这是它们存在的地方。
(假设:您已经创建了一个Twitter应用@dev.twitter.com)
祝您好运!
+6
+1大声笑我想OP可能会找到领域感谢你的小箭头 – ManseUK
+0
Tehehehehehehehehe –
Twitter返回什么错误信息? – abraham