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
| # just want the user's basic info? | |
| sub trim_user { trim_hash(shift, [qw/id name screen_name/]) } | |
| sub trim_list { trim_hash(shift, [qw/name slug id mode description/]) } | |
| sub trim_hash { | |
| my ( $hash, $keys ) = @_; | |
| { map { $_ => $hash->{$_} } @$keys } | |
| } | |
| sub for_each_result { |
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/env perl | |
| use Modern::Perl; | |
| use Net::Twitter; | |
| my $nt = Net::Twitter->new( | |
| traits => [qw/OAuth API::REST RetryOnError/], | |
| consumer_key => 'MkkW2yJ2H1WTWhOIWlw', | |
| consumer_secret => '0oWd3jArJrEFOHUZu6b6NAsJShZoDiDtaLJCmrzdu8', | |
| ); |
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
| #!perl | |
| use warnings; | |
| use strict; | |
| use DBICx::TestDatabase; | |
| use Test::More tests => 3; | |
| use Path::Class qw/file/; | |
| use File::Find; | |
| use lib qw(t/lib); | |
| my $schema = DBICx::TestDatabase->new('My::TestSchema'); |
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 Net::Twitter; | |
| my $nt = Net::Twitter->new(traits => [ | |
| qw/API::REST API::Search InflateObjects RetryOnError AutoCursor/, | |
| AutoCursor => { max_calls => 4, methods => [qw/followers friends/] }, | |
| ]); | |
| print ref $nt, "\n"; | |
| # Net::Twitter::with__API_REST__API_Search__AutoCursor__AutoCursor_1__InflateObjects__RetryOnError |
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/env perl | |
| use warnings; | |
| use strict; | |
| use Net::Twitter; | |
| use Data::Dumper; | |
| my $nt = Net::Twitter->new(traits => [qw/API::REST/]); | |
| # uncomment the following line to simulate a failure | |
| #$nt->ua->add_handler(request_send => sub { HTTP::Response->new(503) }); |
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
| #!/bin/sh | |
| # | |
| # Edit a "journal file" in YYYY-MM-DD.txt format for the current date in | |
| # ~/writings/journal or the specified directory (use '.' for the current | |
| # directory). | |
| EXT="txt" | |
| BASE=$(date +%Y-%m-%d) | |
| DIR=${1:-~/writings/journal} |
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
| #!perl | |
| # Dumping a Twitter request/response | |
| my $nt = Net::Twitter->new(%options); | |
| my $res; | |
| $nt->ua->add_handler(response_done => sub { $res = shift }); | |
| print "Request:\n", | |
| $res->request->as_string, |
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/env perl | |
| use warnings; | |
| use strict; | |
| use Net::Twitter; | |
| use utf8; | |
| use Net::Netrc; | |
| my ($key, $key_secret) = Net::Netrc->lookup('semifor_test-scripts.oauth.twitter')->lpa; | |
| my ($token, $token_secret) = Net::Netrc->lookup('semifor_test.semifor_test-scripts.oauth.twitter')->lpa; |
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
| use Net::Twitter::Lite; | |
| my $nt = Net::Twitter::Lite->new( | |
| consumer_key => $YOUR_CONSUMER_KEY, | |
| consumer_secret => $YOUR_CONSUMER_SECRET, | |
| access_token => $YOUR_ACCESS_TOKEN, | |
| access_token_secret => $YOUR_ACCESS_SECRET, | |
| ); | |
| $nt->update("Bob's your uncle!"); |
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
| package Net::Twitter::Error; | |
| use Moose; | |
| use Try::Tiny; | |
| use Devel::StackTrace; | |
| use overload '""' => \&error, | |
| 'fallback' => 1; | |
| has twitter_error => ( is => 'rw', predicate => 'has_twitter_error' ); | |
| has http_response => ( isa => 'HTTP::Response', is => 'rw', required => 1, handles => [qw/code message/] ); |