Skip to content

Instantly share code, notes, and snippets.

@pmakholm
Created September 18, 2010 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pmakholm/585710 to your computer and use it in GitHub Desktop.
Save pmakholm/585710 to your computer and use it in GitHub Desktop.
Getting OAuth enabled RSS feeds from twitter.com
#!/usr/bin/perl
# Usage:
# - Get you own consumer_key and consumer_secret at http://dev.twitter.com/
# - Add them to $HOME/.get-tweets.json
# - Run this script and follows the directions
# - Run this script with the rss feed url as argument
use feature ':5.10';
use JSON::XS;
use File::Slurp;
use Net::Twitter::Lite;
my $conf = decode_json( read_file( "$ENV{HOME}/.get-tweets.json" ) );
my $url = shift @ARGV;
my $nt = Net::Twitter::Lite->new(
consumer_key => $conf->{consumer_key},
consumer_secret => $conf->{consumer_secret},
);
if ($conf->{access_token} && $conf->{access_token_secret}) {
$nt->access_token($conf->{access_token}); $nt->access_token_secret($conf->{access_token_secret});
}
unless ( $nt->authorized ) {
# The client is not yet authorized: Do it now
say "Authorize this app at ", $nt->get_authorization_url, " and enter the PI
N#";
my $pin = <STDIN>; # wait for input
chomp $pin;
my($access_token, $access_token_secret, $user_id, $screen_name) =
$nt->request_access_token(verifier => $pin);
say "Please add the following keys to $ENV{HOME}/.get-tweets.json";
say "access_token: $access_token";
say "access_token_secret: $access_token_secret";
exit 1;
}
# Everything's ready
say $nt->_oauth_authenticated_request("GET", $url, {}, 1)->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment