Same code, same host, different sites - one works fine - the other 401, code 32 OAuth error


#1

I am using codebird to authenticate on two different sites (two clients). The clients are using the same hosting company (although likely different servers). It works perfectly fine on one site (running wordpress) and fails with code 32, 401 error on the other (running Drupal). Any idea why this could be happening? It’s driving me nuts. Obviously each client has their own app setup with their own keys and tokens. I have checked, double-checked, and re-checked the code that is not authenticating properly. The app causing the problem is the one associated with this account. I have run an account_verify successfully using curl with the request generated from the OAuth Tool in my app. Have also run a statuses/user_timeline request successfully with cURL. I am really at a loss as to why the code works on one site and not on the other. My PHP is below and before you ask, yes they are using the same version of Codebird.

class GetTweets {
	
	static public function get_most_recent($screen_name, $count, $retweets)
	{
		require_once('codebird.php');
	
		$CONSUMER_KEY = '';
		$CONSUMER_SECRET = '';
		$ACCESS_TOKEN = '';
		$ACCESS_TOKEN_SECRET = '';
	
		\Codebird\Codebird::setConsumerKey($CONSUMER_KEY, $CONSUMER_SECRET);
		$cb = \Codebird\Codebird::getInstance();
		$cb->setToken($ACCESS_TOKEN, $ACCESS_TOKEN_SECRET);

		$params = array(
			'screen_name' => $screen_name,
			'count' => $count,
			'rts' => $retweets,
		);
		
	       $tweets = (array) $cb->statuses_userTimeline($params);
		return json_encode($tweets);
	}

}

#2

A request can be rejected if the server timestamp is too far out of sync with Twitter’s servers. What is the exact error body you’re seeing?


#3

Tried again this morning thinking maybe it was a problem with the API, but the issue still exists.


#4

{“errors”:[{“message”:“Could not authenticate you”,“code”:32}],“httpstatus”:401}


#5

Alright…I ran the CURL request created by the OAuth tool from the command line of the server in question and it works fine. I am starting to think it may have something to do with Drupal. I will create a PHP page apart from Drupal on the server and see if I am still seeing the problem…may have something to do with caching of the template files or something. I turned caching off but I am still seeing the issue. Will report back.


#6

Have just tested and it works with a barebones test.php file on the server in question. It is definitely something to do with Drupal. I am running version 6.28. Any help would be awesome if you can think of something off the top of your head. If not, I will report back when I have it figured out.


#7

I never figured this out…It’s a production site, so for the time being I am just scraping the standalone PHP page in the htdocs directory to accomplish my goal. The OAuth request in that file works fine, but apparently something about the Drupal boostrap process does not sit well with the OAuth request, and so I can’t actually make that request inside my template files. If anyone ever comes across this and figures it out…please post your solution as mine is obviously not ideal.


#8

same problem.

Works fine on local but error code 32 on production :frowning:


#9

Same problem… Please Help …


#10

The problem exist cause time of you server not synhronized with twitter time 100% solution

on server run sudo ntpdate -s time.nist.gov for sync clock

and check twitter time with lynx --dump --head https://api.twitter.com/1/help/test.json