Need automatic tweet script or cron job

Discussion in 'PHP' started by rimydalv81, May 25, 2010.

  1. #1
    hi i was wondering if anyone is able to create a script or a cron job to post automatic tweets for me liike every 30 minutes or 45 minutes about 20-40 different default tweets so that it can repeat 24-7... and also i want a cron job or script to go to a website and enter name and password to add followers if you are able to do please pm me
     
    rimydalv81, May 25, 2010 IP
  2. Sergey Popov

    Sergey Popov Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here is the function to post tweets to twitter:

    
    <?php
    function tweet($message, $username, $password) {
      $context = stream_context_create(array(
        'http' => array(
          'method'  => 'POST',
          'header'  => sprintf("Authorization: Basic %s\r\n", base64_encode($username.':'.$password)).
                       "Content-type: application/x-www-form-urlencoded\r\n",
          'content' => http_build_query(array('status' => $message)),
          'timeout' => 5,
        ),
      ));
      $ret = file_get_contents('http://twitter.com/statuses/update.xml', false, $context);
     
      return false !== $ret;
    }
    ?>
    
    PHP:
    If say your script file is tweet.php and you need to run it by cron with given time interval, you can add new task to cron scheduler,
    to call this script. For example, using lynx browser:

    
    lynx -dump http://mysite.com/mydir/tweet.php > /dev/null
    
    Code (markup):
     
    Last edited: May 25, 2010
    Sergey Popov, May 25, 2010 IP