开发者

Twitter and Oauth results in 401 error

开发者 https://www.devze.com 2023-02-16 16:17 出处:网络
I am using Oauth to connect to Twitter, but it results in a 401 error. What am I doing wrong here? //config

I am using Oauth to connect to Twitter, but it results in a 401 error. What am I doing wrong here?

//config
define('CONSUMER_KE开发者_开发百科Y',"");
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;
} 


You get a 401 (Not Authorised) error when you do not provide the correct ConsumerKey and ConsumerSecret values.

Looking at the code above, you are passing empty string values for those two variables. Unless u left them out on purpose, you need to double check your values.

For my app, this is where they exist.

(ASSUMPTION: you've created a twitter application @ dev.twitter.com )

Twitter and Oauth results in 401 error

Good Luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消