Twitter和Oauth导致401错误

Twitter和Oauth导致401错误,oauth,twitter,twitter-oauth,Oauth,Twitter,Twitter Oauth,我正在使用Oauth连接到Twitter,但它会导致401错误。我做错了什么 //config define('CONSUMER_KEY',""); define('CONSUMER_SECRET',""); define('OAUTH_TOKEN',"1U"); define('OAUTH_TOKEN_SECRET',""); require_once('twitteroauth/twitteroauth.php'); $connection = new TwitterOAuth (CON

我正在使用Oauth连接到Twitter,但它会导致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;
} 
如果未提供正确的
ConsumerKey
ConsumerCret
值,则会出现
401(未授权)
错误

查看上面的代码,您正在为这两个变量传递空字符串值。除非你故意漏掉它们,否则你需要仔细检查你的值

对于我的应用程序,这就是它们存在的地方

(假设:您已经创建了一个twitter应用程序@)


祝你好运

Twitter返回了什么错误消息?+1 lol我认为OP可能会因为你的小箭头而找到该字段