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 .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.
No comments:
Post a Comment