Saturday, November 30, 2013

Twitter app using perl - Tweet your status - Part 2

Hi All,
The second part will be simple to update your own status using the perl script.
For that initially, you need to go setting tab.


Under the setting tab, change the permission setting for your app to read , write and acess direct message as given below



Now go to details tab  again and recreate your access token. Be careful to copy the new token generated.



Now the scripting part, I will continue from the place I have left the previous post version of the script .

#!/usr/bin/perl
use Data::Dumper;
use Net::Twitter;
##fill in your dev.twitter stuff below
my $twitterconsumer = "ur_consumer";
my $twitterconsumersecret = "ur_consumer_secret";
my $twitteraccesstoken = "ur_access_token";
my $twitteraccesstokensecret = "ur_access_token_secret";
my $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
consumer_key => $twitterconsumer,
consumer_secret => $twitterconsumersecret,
access_token => $twitteraccesstoken,
access_token_secret => $twitteraccesstokensecret,
);
if (0) {
my $r = $nt->friends;
my @friends = @{$r->{users}};
my %temp = %$r;
# the data stucture is quite complex, I would suggest u
# to print that in file and a to know the various field
print Dumper(\%temp);
foreach my $new_hash (@friends) {
print $new_hash->{'name'},"\n";
}
}
else {
my $twitterStatus = "Hi I \'m twitting this using Net::Twitter";
$nt->update({ status => $twitterStatus });
}

Check out the line no 42, and that will do the magic.
Hope you enjoyed this tutorial. Do comment to let us know about the tutorial

original link : source

No comments:

Post a Comment