Create Your Own Twitter Bot In PHP To Auto Tweet

Create your own twitter bot in php. Twitter is the biggest social media website after facebook. If you can utilize the facilities and infrastructure twitter for promoting your website or online sales, thousands of dollars would be easy you get.

To help us manage the twitter account, dev.twitter as the site developer has provided a twitter API that can be used easily.

In my previous article about Script auto tweet with Imacros and Tweetdeck for Beginner, which allows us to perform an automatic tweet with assistance of iMacros, this time I will discuss how to create twitter bot with php. Auto tweet bot with php can be custom fit to desire. We will learn is basic use twitter API to perform automatic tweet on our twitter account / make a twitter bot to auto-tweet.

 Twitteroauth class to create twitter bot 

We don’t need bother to make a PHP class to communicate with the Twitter API, because a powerful developer named Abraham Williams has provided a PHP class named twitteroauth. Please download the php class as a material to create a twitter bot ( download here ).

Get your free API Key, API secret, access token and access token secret to create twitter bot. 

In order twitteroauth class can run well, we have to create twitter API key. How to Create a Twitter API Key

  1. You have a twitter account
  2. Please login to your twitter account.
  3. Visit
  4. Click the create app
    create new app - create your own twitter bot
  5. Click API Keys Tab
    click api key tabs - create your own twitter bot
  6. Modify application permissions
    modify app permissions - create your own twitter botmodify app permission 2 - create your own twitter bot
  7. Generate Token Key
    generate token key - create your own twitter bot
  8. Refresh. You have completed the initial steps to create twitter bot
    api key and access token - create your own twitter bot

Creating Class in PHP that allows us to call Twitteroauth Class to connect the twitter’s API

How to use the twitter_bot class to do activities tweet / twitter status updates.

Another time I will explain the functions of the twitter`s API, in addition, to auto tweet bot / update status. And I will make the tutorial make a wordpress plugin to automatic tweet. So how to create a twitter bot with PHP, if there are any questions please ask via comment below.

* Update Mei, 1 2015

Hello guys, if you need update of twitteroauth class you can download from twitteroauth class download.

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.


 Add your comment
  1. Been trying to find something like this for ages. Unfortunately, like all the others I’ve found, it doesn’t work. There is no twitteroauth/twitteroauth.php in the package you were referring to. Is this out of date?

  2. bro how to create this app. we need hosting ? or how can u pls explain.
    there is no index file also

  3. FYI: You don’t have a “mention” class, so use the “tweet” class if you’re trying this out. Also check instructions for twitteroauth. It’s using “autoload.php” to load classes etc. now.

  4. what do we put the callback url as? and where do we put the second php script?

  5. Fatal error: Call to undefined method tweet_bot::mention()


    • sory, i have fixed the code

      $api_key=’ Your Twitter API Key’ ;
      $api_secret=’ Your Twitter API Secret’ ;
      $access_token =’ Your Twitter Access Token’ ;
      $access_token_key=’ Your Twitter Access Token Key’ ;
      $tweet= new tweet_bot;
      $tweet->setKey($api_key, $api_secret,$access_token , $access_token_key);
      $result = $tweet->tweet(‘Hello this is my first tweet bot’);

      thanks for correcting

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.