Results 1 to 2 of 2

Thread: Remote Post to Twitter Using Php Curl

  1. #1
    Silver's Avatar
    Silver is offline Administrator
    Join Date
    Dec 2009
    Location
    GrowADollar
    Posts
    325

    Default Remote Post to Twitter Using Php Curl

    Do you wish to post information remotely to your twitter account without having to write it yourself everytime? Using this php script you can send information as tweets to your twitter account.

    A good example of use would be if you wished to notify your followers on twitter when you created a new blog post. To do this you could include the code below when you submit your new blog entry and have it send the title fo the blog linked to the blog page, your followers could then simply click your tweet to view the new blog content.

    PHP Code:
    <?php
    $username 
    "Username Here";
    $password "Password Here";
    $message "status=This is a test post";
    $url "http://twitter.com/statuses/update.xml";
     
     
    $ch curl_init($url);
     
    curl_setopt($chCURLOPT_POST1);
     
    curl_setopt($chCURLOPT_POSTFIELDS$message);
     
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
     
    curl_setopt($chCURLOPT_HEADER0);
     
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
     
    curl_setopt($chCURLOPT_USERPWD"{$username}:{$password}");
     
     
    $message curl_exec($ch);
     
    $httpcode curl_getinfo($chCURLINFO_HTTP_CODE);
     
    curl_close($ch);
     
          if (
    $httpcode != 200)
          {
          echo 
    "Tweet Failed";
          }
    ?>
    The variables are pretty simple to work out what they mean so you just need to put your own values in to have it post the information as a tweet to your account.

  2. #2
    Rocketeer's Avatar
    Rocketeer is offline Member
    Join Date
    Jan 2011
    Location
    USA
    Posts
    30

    Default

    This method will no longer work. Twitter requires you to use OAuth 100% of the time now.

    Twitter API Wiki / OAuth Examples

Similar Threads

  1. Spice up your Twitter posts
    By Silver in forum Search Engine Optimization
    Replies: 1
    Last Post: 01-15-2011, 05:46 PM
  2. Installing Curl on WHM
    By Silver in forum Hosting
    Replies: 3
    Last Post: 08-27-2010, 11:08 PM
  3. Twitter Advertising Platform
    By Silver in forum Advertising
    Replies: 6
    Last Post: 08-26-2010, 11:12 AM
  4. Post Your Website!
    By mwcole83 in forum General Chat
    Replies: 2
    Last Post: 04-26-2010, 12:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •