Could not authenticate you code:32 using TwitterAPIExchange.php


#1

Hi,

My GET calls works perfect but I cant seem to post no matter what I tried. I tried single word statuses, urlencoding etc.

GET (Works)

/** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
$url = ‘https://api.twitter.com/1.1/statuses/mentions_timeline.json’;
$requestMethod = ‘GET’;

/** GET fields required by the URL above. See relevant docs as above **/
$getfield = ‘?count=5’;

/** Perform a POST request and echo the response **/
$twitter = new TwitterAPIExchange($settings);
$txtTwitter = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();

POST (Not working)

/** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
$url = ‘https://api.twitter.com/1.1/statuses/update.json’;
$requestMethod = ‘POST’;

/** POST fields required by the URL above. See relevant docs as above **/
$postfields = array(‘status’=> ‘test’,
‘in_reply_to_status_id’ => ‘rvalsan’
);

/** Perform a POST request and echo the response **/
$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url, $requestMethod)
->setPostfields($postfields)
->performRequest();

Both use the same settings
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
‘oauth_access_token’ => “token”,
‘oauth_access_token_secret’ => “secret”,
‘consumer_key’ => “key”,
‘consumer_secret’ => “secret”
);


#2

Did you know? You can highiight your code samples using the & tags. Many languages sre supported like …