Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Twitter POSTer

by wizbancp (Sexton)
on Feb 12, 2007 at 10:28 UTC ( [id://599526]=sourcecode: print w/replies, xml ) Need Help??
Category: Web Stuff
Author/Contact Info wizbancp
Description: A code for posting update to your twitter account :-)
#!/usr/bin/perl -w

require LWP::UserAgent;

$username = "yourusernamehere";
$password = "yourpasshere";

my $ua = LWP::UserAgent->new;
$ua->agent('WizTwitterBot/1.0');
$ua->timeout(10);
$ua->env_proxy;
$ua->credentials(
    'twitter.com:80',
    'Twitter API',
    $username => $password,);

sub pausa #mette in pausa il programma prima di uscire
{
   print "\nPremi Invio per continuare\n";
   my $pausa = <STDIN>;
} #fine subroutine pausa
  

sub twitter_post {
    $inputtext = shift;
    
    my $update_url = 'http://twitter.com/statuses/update.xml';

    # POST the update to twitter
    my $response = $ua->post($update_url, [status => $inputtext ]);

    # Inform the user if success...
    if ($response->is_success) {
        print "Twitter Updated!!!\n";
    } else {
        print "Update to Twitter failed...\n";
    }

}

print "Insert your update: ";
$update = <STDIN>;
chomp($update);

twitter_post ($update);
pausa;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://599526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found