Twitter API OAuth requestin token



I am working on a sign in for Twitter and am using the OAuth Application. I got it set up and it seemed to work. However, after multiple tests, I unfortunately figured out, that it only works about 20% of the time. The problem has to be the OAuth requestToken procedure

public function getAuthUrl()
	return $this->client->oauth_authenticate();


protected function requestTokens()
	$reply = $this->client->oauth_requestToken(array('oauth_callback' => $this->clientCallback));
	$this->storeTokens($reply->oauth_token, $reply->oauth_token_secret);

This here is the call to this function in my index.php, however, I think that is all correctly coded:

<?php $auth = new TwitterAuth($db, $client); 
    	<?php if($row_Recordset1['twitter_id'] != "0"): ?>
    		<p id="SignedInTwitter">Hello, @<?php echo $row_Recordset1['twitter_username']; ?> </p> 
    	<?php else: ?>
    		<a href="<?php echo $auth->getAuthUrl();?>">Sign in with Twitter</a>
    	<?php endif; ?>

I really need this to work 100% at the time and not only 10% of the time.
If anybody has any ideas, please let me know… I have been trying to fix this for two days now without any success.

Sincerely, Jan Breuer


What’s not working about it? What errors are you getting?


Thanks for your fast reply :slight_smile:
I just get a Website/Server Error 500. Usually the site just cuts off at the point where the code shown above is placed. So I dont really know what the problem is, however, I think it has to do something with the OAuth Token request process!


The 500 error is from your server? You need to debug it and find out what’s causing the 500.


Thanks, I am just learning to work with server and haven’t run into a problem like this before. could you tell me how I debug a server? there isnt a console or anything similar, is there?


Check the documentation for the server you are using to find out hot to look at the logs.


Here is what I found when I was going through the documentation for the server. I find it quite complicated to understand, but maybe you could help me with that?

Thanks a lot for your help. It would be amazing if I could get this sorted, it is driving me nuts since last week


Sounds like your server can’t connect to DNS. Maybe restart it? There are a couple of potential fixes on SO.


Sorry, that I am getting back to you that late. I was away for a week and just got back yesterday. Today I checked the link you posted, however, I couldnt get an answer out of it. Do you have any other idea on how to solve this probem?