简体   繁体   中英

TWITTER API error 220 -: twitteroauth

Good evening all,

I am using the PHP code from https://github.com/abraham/twitteroauth

The login works perfectly but when trying to post a status to Twitter i get the following error:

stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [code] => 220 [message] =>      Your credentials do not allow access to this resource. ) ) )

I am using the following code:

session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'],
$_SESSION['oauth_token_secret']);

$token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);


$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token_credentials['oauth_token'],
$token_credentials['oauth_token_secret']);

$account = $connection->get('account/verify_credentials');
$status = $connection->post('statuses/update', array('status' => 'Text of status here'));

I have followed the same instructions as the website. Where am i going wrong?

In your case do you have to create an api on twitter ? https://apps.twitter.com/ If you did, check the configuration of your api. this link could be helpful. https://dev.twitter.com/docs/auth/oauth/faq

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM