How to Update Your Twitter Status With PHP

Twitter is a social networking site that allows you to share 140-character updates with your online connections. One of the nice features about Twitter is its robust API, which allows developers to use Twitter in a variety of imaginative ways. Using the Twitter API, you can update your status by running a few lines of PHP code. Inserting this code into a PHP HTML file and visiting the page on the Web will result in your Twitter status being updated.

Things You'll Need

  • Twitter account
  • Internet-connected PC
  • Web host with PHP support
Show More

Instructions

    • 1

      Click "Start" > "All Programs" > "Accessories" and select "Notepad."

    • 2

      Select "File" > "Open" and navigate to a copy of your PHP HTML Web page saved on your PC.

    • 3

      Copy and paste the following piece of code after the <body> tag in your Web page:

      /* PHP Update Settings */

      $username = 'myuser';

      $password = 'mypass';

      $format = 'xml'; //alternative: json

      $message = 'This is a Twitter update using PHP';

      /* PHP Update Execution */

      $result = shell_exec('curl http://twitter.com/statuses/update.'.$format.' -u '.$username.':'.$password.' -d status="'.str_replace('"','\"',$message).'"');

      echo $result;

    • 4

      Replace the "myuser" string of text with your Twitter user name and the "mypass" string of text with your Twitter password.

    • 5

      Save the PHP HTML file and upload it to your Web server. If you are unsure how to do this, consult your host's technical support page.

    • 6

      Visit your uploaded Web page on the Internet. When you visit the page, an update will automatically be sent to Twitter that says, "This is a Twitter update using PHP." That text can be altered by editing the "$message" line from Step 3.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured