Hey,
I’m using the tmhOAuth library for my website to link accounts, update statusses, etc. Linking accounts works fine, no errors. But when I’m trying to post a status update, I’m getting this error:
{“error”:“Could not authenticate with OAuth.”,“request”:"/1/account/verify_credentials.json"}
Using the following code:
<?php
/**
* Verify the user token and secret works. If successful we will be given the
* details of the user. If not an error explaining why will be returned.
*
* Although this example uses your user token/secret, you can use
* the user token/secret of any user who has authorised your application.
*
* This example differs from others in that it will reattempt a request if
* the timestamp is detected to be off from the Twitter servers.
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
* http://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
* 4) Visit the 'My Access Token' screen linked to from your application
* details page
* 5) Copy the user token and user secret into the place in this code marked
* with (A_USER_TOKEN and A_USER_SECRET)
* 6) Visit this page using your web browser.
*
* @author themattharris
*/
require '../tmhOAuth.php';
require '../tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => '###########', // Got this from Consumer key
'consumer_secret' => '##################', // Got this from Consumer secret
'user_token' => '###-############', // Got this from Access token
'user_secret' => '#################', // Got this from Access token secret
));
// for the demo set the timestamp to yesterday
$tmhOAuth->config['force_timestamp'] = true;
$tmhOAuth->config['timestamp'] = strtotime('yesterday');
$code = tmhUtilities::auto_fix_time_request($tmhOAuth, 'GET', $tmhOAuth->url('1/account/verify_credentials'));
if ($code == 200) {
if ($tmhOAuth->auto_fixed_time)
echo 'Had to auto adjust the time. Please check the date and time is correct on your device/server';
tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
} else {
tmhUtilities::pr(htmlentities($tmhOAuth->response['response']));
}
?>
Access level: R&W+DM
I think there is a problem with the user_token and the user_secret. I already searched the interwebs for solutions, I also found this exact problem, but none of the solutions work.
Please help me.
Thanks.
PS. I also saw some threads with formatted code. How do I do that?