Tuesday, November 29, 2011

Post to Twitter Using Perl

Salam,

cara paling mudah so far nak post ke twitter.com dari perl script.

guna module Net::Twitter::Lite dari cpan.

  
use Net::Twitter::Lite;

my $nt = Net::Twitter::Lite->new(
 consumer_key        => '',
 consumer_secret     => '',
 access_token        => '',
 access_token_secret => ''
);

my $result = eval { $nt->update("$tweettext") };
if([email protected]){
 print "Problem when posting Ads to Twitter.com\n";
 print "[email protected]\n";
}else{
 print "$result";
}

* untuk key & token boleh dapat dari twitter developer punya section. hanya pelu register kita punya apps.

No comments: