Post Tweet to Twitter Not Working


I watch this video ( to learn how to post a tweet to Twitter account using PHP. I grab the PHP he give in the video description ( & add my Application & Access Token details inside the script.

This is my code (

The github repo for this script is here - (‘OAuth.php’ and ‘twitteroauth.php’ files inside the ‘twitteroauth’ folder).


When I run my code with localhost (using MAMP), the tweet successfully sent to my Twitter account.

But, when I put it on my web hosting account and run the code, the tweet not sent to my Twitter account even I still get the success message like below.

How to fix this problem? Why the tweet is not sent and only sent successfully in localhost mode?

This is my Application & Token Access details (it’s same like in my code):

I also have asked this on Stack Overflow (, but I got no answer. Please help me.