Permalink
Browse files

Twitter now requires SSL connections

  • Loading branch information...
1 parent 7878f51 commit f6cccd1d6ab2e7a46c96266068afc8287771c6fc @semifor committed Jan 17, 2014
View
@@ -1,3 +1,6 @@
+0.12005 2014-01-17
+ - Twitter now requires SSL connections
+
0.12004 2013-05-03
- restore list_subscriptions
@@ -21,7 +21,7 @@
my (undef, undef, $datafile) = File::Spec->splitpath($0);
$datafile =~ s/\..*/.dat/;
-my $nt = Net::Twitter::Lite::WithAPIv1_1->new(%consumer_tokens);
+my $nt = Net::Twitter::Lite::WithAPIv1_1->new(ssl => 1, %consumer_tokens);
my $access_tokens = eval { retrieve($datafile) } || [];
if ( @$access_tokens ) {
View
@@ -19,7 +19,8 @@ package MyWebApp;
my $server_port = 8080;
-sub twitter { shift->{twitter} ||= Net::Twitter::Lite::WithAPIv1_1->new(%consumer_tokens) }
+sub twitter { shift->{twitter} ||= Net::Twitter::Lite::WithAPIv1_1->new(
+ ssl => 1, %consumer_tokens) }
my %dispatch = (
'/oauth_callback' => \&oauth_callback,
View
@@ -1,4 +1,5 @@
package Net::Twitter::Lite;
+our $VERSION = '0.12005';
use 5.005;
use warnings;
use strict;
@@ -9,8 +10,6 @@ Net::Twitter::Lite - A perl library for Twitter's API v1
=cut
-our $VERSION = '0.12004';
-
use Carp;
use URI::Escape;
use JSON;
@@ -17,8 +17,27 @@ sub _default_lists_api_url () { 'http://api.twitter.com/1.1' }
sub new {
my $class = shift;
+ my %options = @_;
- return $class->SUPER::new(legacy_lists_api => 0, @_);
+ # Twitter now requires SSL connections. Since Net::Twitter::Lite is used
+ # for Twitter API compatible services that may not require, or indeed allow
+ # SSL, we won't change the default, yet. We'll have a deprecation cycle
+ # where we warn users if they don't have an ssl option set and let them
+ # know enabling ssl will be the default in the future.
+ unless ( exists $options{ssl} ) {
+ warn <<'';
+The Twitter API now requires SSL. Add ( ssl => 1 ) to the options passed to new
+to enable it. For backwards compatibility, SSL is disabled by default in this
+version. Passing the ssl option to new will disable this warning. If you are
+using a Twitter API compatbile service that does not support SSL, add
+( ssl => 0 ) to disable this warning and preserve non-SSL connections in future
+upgrades.
+
+ $options{ssl} = 0;
+ }
+
+
+ return $class->SUPER::new(legacy_lists_api => 0, %options);
}
1;
@@ -14,6 +14,7 @@ Net::Twitter::Lite::WithAPIv1_1 - A perl interface to the Twitter API
consumer_secret => $consumer_secret,
access_token => $token,
access_token_secret => $token_secret,
+ ssl => 1,
);
my $result = $nt->update('Hello, world!');
@@ -32,6 +33,34 @@ Net::Twitter::Lite::WithAPIv1_1 - A perl interface to the Twitter API
"Twitter error.....: ", $err->error, "\n";
}
+=head1 TWITTER NOW REQUIRES SSL
+
+B<Deprecation cycle>. Twitter now requires SSL connections for API calls. To
+enable SSL, add C<( ssl =E<gt> 1)> to the options passed to new. E.g.,
+
+ my $nt = Net::Twitter::Lite::WithAPIv1_1->new(
+ consumer_key => $key,
+ consumer_secret => $secret,
+ access_token => $token,
+ access_token_secret => $token_secret,
+ ssl => 1, ## enable SSL! ##
+ );
+
+This version will warn if no C<ssl> option is passed to C<new>. For backwards
+compatibility, the default in this version remains SSL disabled. A future
+release will change the default to SSL enabled and remove the warning. Add
+C<( ssl =E<gt> 0 )> to disable the warning and keep SSL disabled.
+
+B<Why not just make the default SSL enabled, now?> Net::Twitter::Lite has
+always tried to adhere to a strict policy of backwards compatibility. An
+upgrade to Net::Twitter::Lite should not break or significantly change the
+behavior of existing code that relies on it. Net::Twitter is used by some for
+Twitter API compatible services that may or may not require SSL, and for some
+private test services that require non-SSL connections. They shouldn't break
+when Net::Twitter::Lite is upgraded. This deprecation cycle is the minimally
+invasive change that lets user know about Twitter's change without
+significantly changing the behavior for anyone upgrading.
+
=head1 DESCRIPTION
This module provides a perl interface to the Twitter APIs. See
View
@@ -50,7 +50,7 @@ plan tests => @tests * 4 + 2;
use_ok 'Net::Twitter::Lite::WithAPIv1_1';
-my $nt = Net::Twitter::Lite::WithAPIv1_1->new;
+my $nt = Net::Twitter::Lite::WithAPIv1_1->new(ssl => 1);
isa_ok $nt, 'Net::Twitter::Lite::WithAPIv1_1';
my $ua = $nt->{ua};

0 comments on commit f6cccd1

Please sign in to comment.