Skip to content

Instantly share code, notes, and snippets.

# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# The Perl version
tweet() {
perl -MNet::Twitter::Lite -E'say Net::Twitter::Lite->new(ssl=>1,netrc=>1)->update("@ARGV")->{id}' $*
}
#!/usr/bin/perl
use warnings;
use strict;
use lib qw/lib/;
use Test::More tests => 41;
#------------------------------- Object::Simple -------------------------------
use Object::Simple;
my $o = Object::Simple->new(1);
#!/usr/bin/perl
# Net::Twitter - decoded character vs. encoded byte example
use warnings;
use strict;
use utf8;
# This program produced the following:
#
# http://twitter.com/semifor_test/status/2910290982
# http://twitter.com/semifor_test/status/2910312937
$ git push --tags origin master
Counting objects: 32, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 1.52 KiB, done.
Total 17 (delta 12), reused 0 (delta 0)
error: file write error (No space left on device)
fatal: unable to write sha1 file
error: unpack failed: unpacker exited with error code
To [email protected]:semifor/Net-Twitter.git
#!/usr/bin/perl
# Accessing the HTTP::Response object on successful Net::Twitter API calls
use warnings;
use strict;
use Net::Twitter;
my $nt = Net::Twitter->new(netrc => 1, legacy => 0);
my $response;
diff --git a/lib/Net/Twitter/Core.pm b/lib/Net/Twitter/Core.pm
index f52207c..3011089 100644
--- a/lib/Net/Twitter/Core.pm
+++ b/lib/Net/Twitter/Core.pm
@@ -86,7 +86,7 @@ sub _authenticated_request {
my $msg;
- $_ = encode('utf-8', $_) for values %$args;
+ $_ = encode('utf-8', $_) for keys %$args, values %$args;
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode qw/encode_utf8/;
use Net::Twitter;
diff --git a/lib/Net/Twitter/Core.pm b/lib/Net/Twitter/Core.pm
index 3011089..bf3c6c2 100644
--- a/lib/Net/Twitter/Core.pm
+++ b/lib/Net/Twitter/Core.pm
@@ -86,7 +86,7 @@ sub _authenticated_request {
my $msg;
- $_ = encode('utf-8', $_) for keys %$args, values %$args;
+ $args = { map { encode('utf-8', $_) } %$args };
#!/usr/bin/env perl
# top-followed-by-friends
#
# Prints a list of the users most followed by your friends, but not you.
#
# usage: top-followed-by-friends [twitter-screen_name-or-id]
#
# Throttles Twitter API calls so you don't get rate limited.
# Uses Cache::FileCache for storage. Set $cache_dir to something more
# permanent than /tmp if you want to keep the cache alive longer.
#!/usr/bin/env perl
# unicode test
use strict;
use warnings;
use feature ':5.10';
use Carp qw/confess/;
use Encode qw/decode_utf8/;
use Net::Twitter;