Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r9505: LJSUP-6780 (Twitter Digest): move LJ::AP...

Committer: ailyin
LJSUP-6780 (Twitter Digest): move LJ::API::Twitter to LJ::Client::Twitter to disambiguate the LJ::API namespace; no functional changes
D   trunk/cgi-bin/LJ/API/Twitter.pm
A   trunk/cgi-bin/LJ/Client/
A   trunk/cgi-bin/LJ/Client/Twitter.pm
U   trunk/cgi-bin/LJ/Hooks/Cleanup.pm
U   trunk/cgi-bin/LJ/Setting/TwitterConnect.pm
U   trunk/cgi-bin/LJ/Worker/Repost/CommentToTwitter.pm
U   trunk/cgi-bin/LJ/Worker/Repost/EntryToTwitter.pm
U   trunk/cvs/killfile-local.conf
U   trunk/htdocs/manage/settings/twitter.bml
Deleted: trunk/cgi-bin/LJ/API/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/API/Twitter.pm	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cgi-bin/LJ/API/Twitter.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -1,328 +0,0 @@
-package LJ::API::Twitter;
-use strict;
-
-use Net::OAuth;
-$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
-use Net::OAuth::RequestTokenRequest;
-use Net::OAuth::AccessTokenRequest;
-use Net::OAuth::ProtectedResourceRequest;
-use HTTP::Request::Common;
-
-=head1 NAME
-
-LJ::API::Twitter - the module that handles communication between LJ
-and Twitter.
-
-=head1 SYNOPSIS
-
- use LJ::API::Twitter;
- 
- # request an OAuth request token
- my $req_token = LJ::API::Twitter->request_request_token;
- 
- # redirect to Twitter where one can confirm that they trust us
- LJ::Request->redirect( 'https://api.twitter.com/oauth/authorize?' .
-                        'oauth_token=' . $req_token->{'public'} );
- 
- # once the Twitter redirects the user back, get back our token
- # in full, along with the verifier
- my $public = LJ::Request->get_param('oauth_token');
- my $req_token = LJ::API::Twitter->fetch_request_token($public);
- my $verifier = LJ::Request->get_param('oauth_verifier');
- 
- # get the OAuth access token from Twitter and save it
- my $access_token = LJ::API::Twitter->request_access_token(
-    $req_token, $verifier);
- $u->prop( 'twitter_access_token'        => $access_token->{'public'} );
- $u->prop( 'twitter_access_token_secret' => $access_token->{'secret'} );
- 
- # use the token to call the API
- LJ::API::Twitter->call(
-    'api_method'   => 'account/verify_credentials',
-    'access_token' => $access_token,
- );
- 
- # alternatively, access token can be extracted from userprops
- LJ::API::Twitter->call(
-    'api_method' => 'account/verify_credentials',
-    'user'       => $u,
- );
- 
- # we can haz POST requests as well
- LJ::API::Twitter->call(
-    'api_method' => 'statuses/update',
-    'user' => $u,
-    'http_method' => 'POST',
-    'params' => { 'status' => $status },
- );
- 
- # the module saves request_token public/secret mapping
- # in the DB, so every so often you may want to clear that
- LJ::API::Twitter->remove_request_token($req_token);
- LJ::API::Twitter->clean_stale_request_tokens;
-
-=head1 SEE ALSO
-
-Twitter API Documentation: http://dev.twitter.com/doc
-
-This module is primarily used for reposting, so
-LJ::Setting::TwitterConnect,
-LJ::Hooks::ThirdPartyNotify,
-LJ::Worker::Repost::EntryToTwitter.pm,
-LJ::Worker::Repost::CommentToTwitter.pm
-
-=cut
-
-sub generate_nonce {
-    return time . '/' . LJ::rand_chars(20);
-}
-
-sub default_request_params {
-    return (
-        consumer_key => $LJ::TWITTER_CONSUMER_KEY,
-        consumer_secret => $LJ::TWITTER_CONSUMER_SECRET,
-        request_method => 'POST',
-        signature_method => 'HMAC-SHA1',
-        timestamp => time,
-        nonce => generate_nonce,
-    );
-}
-
-sub request_request_token {
-    my ($class) = @_;
-
-    my $request = Net::OAuth::RequestTokenRequest->new(
-        $class->default_request_params,
-        request_url => 'https://api.twitter.com/oauth/request_token',
-        callback => "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect",
-    );
-
-    $request->sign;
-
-    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
-    my $res = $ua->post($request->to_url);
-
-    unless ($res->is_success) {
-        require Data::Dumper;
-        warn 'twitter connectivity error: ' .
-             Data::Dumper::Dumper($res);
-
-        die "twitter connectivity error";
-    }
-
-    my %params_returned;
-    LJ::decode_url_string($res->content, \%params_returned);
-
-    my $token = {
-        'public' => $params_returned{'oauth_token'},
-        'secret' => $params_returned{'oauth_token_secret'},
-    };
-
-    $class->store_request_token($token);
-
-    return $token;
-}
-
-sub request_access_token {
-    my ($class, $request_token, $verifier) = @_;
-
-    my $request = Net::OAuth::AccessTokenRequest->new(
-        $class->default_request_params,
-        token => $request_token->{'public'},
-        token_secret => $request_token->{'secret'},
-        verifier => $verifier,
-        request_url => 'https://api.twitter.com/oauth/access_token',
-        callback => "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect",
-    );
-
-    $request->sign;
-
-    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
-    my $res = $ua->post($request->to_url);
-
-    unless ($res->is_success) {
-        require Data::Dumper;
-        warn 'twitter connectivity error: ' .
-             Data::Dumper::Dumper($res);
-
-        die "twitter connectivity error";
-    }
-
-    my %params_returned;
-    LJ::decode_url_string($res->content, \%params_returned);
-
-    my $token = {
-        'public' => $params_returned{'oauth_token'},
-        'secret' => $params_returned{'oauth_token_secret'},
-    };
-
-    return $token;
-}
-
-sub call {
-    my ($class, %opts) = @_;
-
-    my $api_method  = $opts{'api_method'};
-    die 'API method not provided' unless $api_method;
-
-    if (my $u = $opts{'user'}) {
-        $opts{'access_token'} = {
-            'public' => $u->prop('twitter_access_token'),
-            'secret' => $u->prop('twitter_access_token_secret'),
-        };
-    }
-
-    my $access_token = $opts{'access_token'};
-    die 'access token not provided' unless $access_token;
-
-    my $http_method = $opts{'http_method'} || 'GET';
-    die 'invalid HTTP method' unless $http_method =~ /^(?:GET|POST)$/;
-
-    my $extra_params  = $opts{'params'}  || {};
-    
-    ##
-    ## Net::OAuth, Twitter, LJ and Unicode strings.
-    ##
-    ## Net::OAuth::Message uses URI::Escape::uri_escape_utf8, 
-    ## which processes byte strings incorrectly (double utf encoding):
-    ##
-    ##      print URI::Escape::uri_escape_utf8("я", '^\w.~-');
-    ##
-    ## When wide-char strings are used (with utf8 flag on), 
-    ## then they are not encoded to utf8 (byte) strings
-    ## before passing to Twitter:
-    ##
-    ##      my $request = Net::OAuth::Request->new(
-    ##          extra_params => { status => Encode::decode_utf8("я"), }
-    ##      );
-    ##      print Data::Dumper::Dumper( $request->to_hash );
-    ##
-
-    my %params = $class->default_request_params;
-    $params{'request_method'} = $http_method;
-
-    my $request_url = 'https://api.twitter.com/1/' . $api_method . '.json';
-
-    ##
-    ## turn UTF-8 flag ON here, 
-    ## don't change elements of original hash (caller's params)
-    ##
-    my %extra_params;
-    while (my ($k, $v) = each %$extra_params) {
-        $extra_params{$k} = Encode::decode_utf8($v);
-    }
-
-    my $request = Net::OAuth::ProtectedResourceRequest->new(
-        %params,
-        token => $access_token->{'public'},
-        token_secret => $access_token->{'secret'},
-        request_url => $request_url,
-        extra_params => \%extra_params,
-    );
-
-    $request->sign;
-
-    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
-    my $res;
-    if ($http_method eq 'GET') {
-        $res = $ua->get($request->to_url);
-    } else {
-        ##
-        ## turn UTF-8 flag OFF here,
-        ## TODO: what to do with GET requests?
-        ##
-        my $post_params = $request->to_hash;
-        while (my ($k, $v) = each %$post_params) {
-            $post_params->{$k} = Encode::encode_utf8($v);
-        }
-        $res = $ua->post( $request_url, $post_params );
-    }
-
-    unless ($res->is_success) {
-        require Data::Dumper;
-        warn 'twitter connectivity error: ' .
-             Data::Dumper::Dumper($res);
-
-        die "twitter connectivity error";
-    }
-
-    return LJ::JSON->from_json($res->content);
-}
-
-sub store_request_token {
-    my ($class, $token) = @_;
-
-    my $dbh = LJ::get_db_writer();
-    $dbh->{'RaiseError'} = 1;
-    $dbh->do(qq{
-        REPLACE INTO twitter_request_tokens
-        SET public=?, secret=?, issued=UNIX_TIMESTAMP()
-    }, undef, $token->{'public'}, $token->{'secret'});
-
-    LJ::MemCache::set(
-        'twitter_secret:' . $token->{'public'} => $token->{'secret'}
-    );
-}
-
-sub fetch_request_token {
-    my ($class, $public) = @_;
-
-    my $secret = LJ::MemCache::get("twitter_secret:$public");
-
-    unless ($secret) {
-        my $dbh = LJ::get_db_writer();
-        $dbh->{'RaiseError'} = 1;
-        ($secret) = $dbh->selectrow_array(qq{
-            SELECT secret FROM twitter_request_tokens WHERE public=?
-        }, undef, $public);
-
-        unless ($secret) {
-            warn 'couldn\'t get a Twitter secret by their public '.
-                 'request token: ' . $public;
-            return;
-        }
-
-        LJ::MemCache::set("twitter_secret:$public" => $secret);
-    }
-
-    return {
-        'public' => $public,
-        'secret' => $secret,
-    };
-}
-
-sub remove_request_token {
-    my ($class, $public) = @_;
-
-    my $dbh = LJ::get_db_writer();
-    $dbh->{'RaiseError'} = 1;
-    $dbh->do(qq{
-        DELETE FROM twitter_request_tokens WHERE public=?
-    }, undef, $public);
-
-    LJ::MemCache::delete("twitter_secret:$public");
-}
-
-sub clean_stale_request_tokens {
-    my ($class) = @_;
-
-    # we store them for a day
-    my $time_stale = time - 86400;
-
-    ## 
-    ## This is a hack to work around the following error:
-    ## DBD::mysql::db do failed: MySQL server has gone away
-    ## The real problem is that LJ::get_db_writer() doesn't check
-    ## cached connection handle before returning it.
-    ##
-    LJ::start_request();   
-
-    my $dbh = LJ::get_db_writer();
-    $dbh->{'RaiseError'} = 1;
-    $dbh->do(
-        'DELETE FROM twitter_request_tokens WHERE issued < ?',
-        undef, $time_stale
-    );
-}
-
-1;

Added: trunk/cgi-bin/LJ/Client/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Twitter.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Client/Twitter.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -0,0 +1,328 @@
+package LJ::Client::Twitter;
+use strict;
+
+use Net::OAuth;
+$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
+use Net::OAuth::RequestTokenRequest;
+use Net::OAuth::AccessTokenRequest;
+use Net::OAuth::ProtectedResourceRequest;
+use HTTP::Request::Common;
+
+=head1 NAME
+
+LJ::Client::Twitter - the module that handles communication between LJ
+and Twitter.
+
+=head1 SYNOPSIS
+
+ use LJ::Client::Twitter;
+ 
+ # request an OAuth request token
+ my $req_token = LJ::Client::Twitter->request_request_token;
+ 
+ # redirect to Twitter where one can confirm that they trust us
+ LJ::Request->redirect( 'https://api.twitter.com/oauth/authorize?' .
+                        'oauth_token=' . $req_token->{'public'} );
+ 
+ # once the Twitter redirects the user back, get back our token
+ # in full, along with the verifier
+ my $public = LJ::Request->get_param('oauth_token');
+ my $req_token = LJ::Client::Twitter->fetch_request_token($public);
+ my $verifier = LJ::Request->get_param('oauth_verifier');
+ 
+ # get the OAuth access token from Twitter and save it
+ my $access_token = LJ::Client::Twitter->request_access_token(
+    $req_token, $verifier);
+ $u->prop( 'twitter_access_token'        => $access_token->{'public'} );
+ $u->prop( 'twitter_access_token_secret' => $access_token->{'secret'} );
+ 
+ # use the token to call the API
+ LJ::Client::Twitter->call(
+    'api_method'   => 'account/verify_credentials',
+    'access_token' => $access_token,
+ );
+ 
+ # alternatively, access token can be extracted from userprops
+ LJ::Client::Twitter->call(
+    'api_method' => 'account/verify_credentials',
+    'user'       => $u,
+ );
+ 
+ # we can haz POST requests as well
+ LJ::Client::Twitter->call(
+    'api_method' => 'statuses/update',
+    'user' => $u,
+    'http_method' => 'POST',
+    'params' => { 'status' => $status },
+ );
+ 
+ # the module saves request_token public/secret mapping
+ # in the DB, so every so often you may want to clear that
+ LJ::Client::Twitter->remove_request_token($req_token);
+ LJ::Client::Twitter->clean_stale_request_tokens;
+
+=head1 SEE ALSO
+
+Twitter API Documentation: http://dev.twitter.com/doc
+
+This module is primarily used for reposting, so
+LJ::Setting::TwitterConnect,
+LJ::Hooks::ThirdPartyNotify,
+LJ::Worker::Repost::EntryToTwitter.pm,
+LJ::Worker::Repost::CommentToTwitter.pm
+
+=cut
+
+sub generate_nonce {
+    return time . '/' . LJ::rand_chars(20);
+}
+
+sub default_request_params {
+    return (
+        consumer_key => $LJ::TWITTER_CONSUMER_KEY,
+        consumer_secret => $LJ::TWITTER_CONSUMER_SECRET,
+        request_method => 'POST',
+        signature_method => 'HMAC-SHA1',
+        timestamp => time,
+        nonce => generate_nonce,
+    );
+}
+
+sub request_request_token {
+    my ($class) = @_;
+
+    my $request = Net::OAuth::RequestTokenRequest->new(
+        $class->default_request_params,
+        request_url => 'https://api.twitter.com/oauth/request_token',
+        callback => "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect",
+    );
+
+    $request->sign;
+
+    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
+    my $res = $ua->post($request->to_url);
+
+    unless ($res->is_success) {
+        require Data::Dumper;
+        warn 'twitter connectivity error: ' .
+             Data::Dumper::Dumper($res);
+
+        die "twitter connectivity error";
+    }
+
+    my %params_returned;
+    LJ::decode_url_string($res->content, \%params_returned);
+
+    my $token = {
+        'public' => $params_returned{'oauth_token'},
+        'secret' => $params_returned{'oauth_token_secret'},
+    };
+
+    $class->store_request_token($token);
+
+    return $token;
+}
+
+sub request_access_token {
+    my ($class, $request_token, $verifier) = @_;
+
+    my $request = Net::OAuth::AccessTokenRequest->new(
+        $class->default_request_params,
+        token => $request_token->{'public'},
+        token_secret => $request_token->{'secret'},
+        verifier => $verifier,
+        request_url => 'https://api.twitter.com/oauth/access_token',
+        callback => "$LJ::SITEROOT/manage/settings/twitter.bml?act=connect",
+    );
+
+    $request->sign;
+
+    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
+    my $res = $ua->post($request->to_url);
+
+    unless ($res->is_success) {
+        require Data::Dumper;
+        warn 'twitter connectivity error: ' .
+             Data::Dumper::Dumper($res);
+
+        die "twitter connectivity error";
+    }
+
+    my %params_returned;
+    LJ::decode_url_string($res->content, \%params_returned);
+
+    my $token = {
+        'public' => $params_returned{'oauth_token'},
+        'secret' => $params_returned{'oauth_token_secret'},
+    };
+
+    return $token;
+}
+
+sub call {
+    my ($class, %opts) = @_;
+
+    my $api_method  = $opts{'api_method'};
+    die 'API method not provided' unless $api_method;
+
+    if (my $u = $opts{'user'}) {
+        $opts{'access_token'} = {
+            'public' => $u->prop('twitter_access_token'),
+            'secret' => $u->prop('twitter_access_token_secret'),
+        };
+    }
+
+    my $access_token = $opts{'access_token'};
+    die 'access token not provided' unless $access_token;
+
+    my $http_method = $opts{'http_method'} || 'GET';
+    die 'invalid HTTP method' unless $http_method =~ /^(?:GET|POST)$/;
+
+    my $extra_params  = $opts{'params'}  || {};
+    
+    ##
+    ## Net::OAuth, Twitter, LJ and Unicode strings.
+    ##
+    ## Net::OAuth::Message uses URI::Escape::uri_escape_utf8, 
+    ## which processes byte strings incorrectly (double utf encoding):
+    ##
+    ##      print URI::Escape::uri_escape_utf8("я", '^\w.~-');
+    ##
+    ## When wide-char strings are used (with utf8 flag on), 
+    ## then they are not encoded to utf8 (byte) strings
+    ## before passing to Twitter:
+    ##
+    ##      my $request = Net::OAuth::Request->new(
+    ##          extra_params => { status => Encode::decode_utf8("я"), }
+    ##      );
+    ##      print Data::Dumper::Dumper( $request->to_hash );
+    ##
+
+    my %params = $class->default_request_params;
+    $params{'request_method'} = $http_method;
+
+    my $request_url = 'https://api.twitter.com/1/' . $api_method . '.json';
+
+    ##
+    ## turn UTF-8 flag ON here, 
+    ## don't change elements of original hash (caller's params)
+    ##
+    my %extra_params;
+    while (my ($k, $v) = each %$extra_params) {
+        $extra_params{$k} = Encode::decode_utf8($v);
+    }
+
+    my $request = Net::OAuth::ProtectedResourceRequest->new(
+        %params,
+        token => $access_token->{'public'},
+        token_secret => $access_token->{'secret'},
+        request_url => $request_url,
+        extra_params => \%extra_params,
+    );
+
+    $request->sign;
+
+    my $ua = LJ::get_useragent( 'role' => 'twitter_auth' );
+    my $res;
+    if ($http_method eq 'GET') {
+        $res = $ua->get($request->to_url);
+    } else {
+        ##
+        ## turn UTF-8 flag OFF here,
+        ## TODO: what to do with GET requests?
+        ##
+        my $post_params = $request->to_hash;
+        while (my ($k, $v) = each %$post_params) {
+            $post_params->{$k} = Encode::encode_utf8($v);
+        }
+        $res = $ua->post( $request_url, $post_params );
+    }
+
+    unless ($res->is_success) {
+        require Data::Dumper;
+        warn 'twitter connectivity error: ' .
+             Data::Dumper::Dumper($res);
+
+        die "twitter connectivity error";
+    }
+
+    return LJ::JSON->from_json($res->content);
+}
+
+sub store_request_token {
+    my ($class, $token) = @_;
+
+    my $dbh = LJ::get_db_writer();
+    $dbh->{'RaiseError'} = 1;
+    $dbh->do(qq{
+        REPLACE INTO twitter_request_tokens
+        SET public=?, secret=?, issued=UNIX_TIMESTAMP()
+    }, undef, $token->{'public'}, $token->{'secret'});
+
+    LJ::MemCache::set(
+        'twitter_secret:' . $token->{'public'} => $token->{'secret'}
+    );
+}
+
+sub fetch_request_token {
+    my ($class, $public) = @_;
+
+    my $secret = LJ::MemCache::get("twitter_secret:$public");
+
+    unless ($secret) {
+        my $dbh = LJ::get_db_writer();
+        $dbh->{'RaiseError'} = 1;
+        ($secret) = $dbh->selectrow_array(qq{
+            SELECT secret FROM twitter_request_tokens WHERE public=?
+        }, undef, $public);
+
+        unless ($secret) {
+            warn 'couldn\'t get a Twitter secret by their public '.
+                 'request token: ' . $public;
+            return;
+        }
+
+        LJ::MemCache::set("twitter_secret:$public" => $secret);
+    }
+
+    return {
+        'public' => $public,
+        'secret' => $secret,
+    };
+}
+
+sub remove_request_token {
+    my ($class, $public) = @_;
+
+    my $dbh = LJ::get_db_writer();
+    $dbh->{'RaiseError'} = 1;
+    $dbh->do(qq{
+        DELETE FROM twitter_request_tokens WHERE public=?
+    }, undef, $public);
+
+    LJ::MemCache::delete("twitter_secret:$public");
+}
+
+sub clean_stale_request_tokens {
+    my ($class) = @_;
+
+    # we store them for a day
+    my $time_stale = time - 86400;
+
+    ## 
+    ## This is a hack to work around the following error:
+    ## DBD::mysql::db do failed: MySQL server has gone away
+    ## The real problem is that LJ::get_db_writer() doesn't check
+    ## cached connection handle before returning it.
+    ##
+    LJ::start_request();   
+
+    my $dbh = LJ::get_db_writer();
+    $dbh->{'RaiseError'} = 1;
+    $dbh->do(
+        'DELETE FROM twitter_request_tokens WHERE issued < ?',
+        undef, $time_stale
+    );
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Hooks/Cleanup.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/Cleanup.pm	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cgi-bin/LJ/Hooks/Cleanup.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -1,10 +1,10 @@
 package LJ::Hooks::Cleanup;
 use strict;
 
-use LJ::API::Twitter;
+use LJ::Client::Twitter;
 
 LJ::register_hook('extra_cache_clean', sub {
-    LJ::API::Twitter->clean_stale_request_tokens;
+    LJ::Client::Twitter->clean_stale_request_tokens;
 });
 
 1;

Modified: trunk/cgi-bin/LJ/Setting/TwitterConnect.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/TwitterConnect.pm	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cgi-bin/LJ/Setting/TwitterConnect.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use LJ::API::Twitter;
+use LJ::Client::Twitter;
 
 sub should_render {
     my ( $class, $u ) = @_;
@@ -72,7 +72,7 @@
     my ( $class, $u, $args ) = @_;
 
     if ( $class->get_arg( $args, "connect" ) ) {
-        my $token = LJ::API::Twitter->request_request_token;
+        my $token = LJ::Client::Twitter->request_request_token;
         my $addr  = 'https://api.twitter.com/oauth/authorize?' .
                     'oauth_token=' . $token->{'public'};
 

Modified: trunk/cgi-bin/LJ/Worker/Repost/CommentToTwitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Worker/Repost/CommentToTwitter.pm	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cgi-bin/LJ/Worker/Repost/CommentToTwitter.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -3,7 +3,7 @@
 
 use base qw(LJ::Worker::Repost);
 use LJ::Text;
-use LJ::API::Twitter;
+use LJ::Client::Twitter;
 
 sub work {
     my ($class, $job) = @_;
@@ -30,7 +30,7 @@
 
     my $status = "$title $short_url";
 
-    LJ::API::Twitter->call(
+    LJ::Client::Twitter->call(
         'api_method' => 'statuses/update',
         'user' => $poster,
         'http_method' => 'POST',

Modified: trunk/cgi-bin/LJ/Worker/Repost/EntryToTwitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Worker/Repost/EntryToTwitter.pm	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cgi-bin/LJ/Worker/Repost/EntryToTwitter.pm	2010-09-15 07:09:04 UTC (rev 9505)
@@ -3,7 +3,7 @@
 
 use base qw(LJ::Worker::Repost);
 use LJ::Text;
-use LJ::API::Twitter;
+use LJ::Client::Twitter;
 
 sub work {
     my ($class, $job) = @_;
@@ -30,7 +30,7 @@
 
     my $status = "$title $short_url";
 
-    LJ::API::Twitter->call(
+    LJ::Client::Twitter->call(
         'api_method' => 'statuses/update',
         'user' => $poster,
         'http_method' => 'POST',

Modified: trunk/cvs/killfile-local.conf
===================================================================
--- trunk/cvs/killfile-local.conf	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/cvs/killfile-local.conf	2010-09-15 07:09:04 UTC (rev 9505)
@@ -1,3 +1,4 @@
 cgi-bin/LJ/Widget/ShopVGift.pm
 cgi-bin/LJ/Widget/ShopVGiftItem.pm
 cgi-bin/LJ/Bitly.pm
+cgi-bin/LJ/API/Twitter.pm

Modified: trunk/htdocs/manage/settings/twitter.bml
===================================================================
--- trunk/htdocs/manage/settings/twitter.bml	2010-09-15 04:53:18 UTC (rev 9504)
+++ trunk/htdocs/manage/settings/twitter.bml	2010-09-15 07:09:04 UTC (rev 9505)
@@ -6,7 +6,7 @@
     use strict;
     use vars qw(%GET %POST $title $headextra @errors @warnings);
 
-    use LJ::API::Twitter;
+    use LJ::Client::Twitter;
 
     $title = LJ::Lang::ml('.title');
 
@@ -45,8 +45,8 @@
             return LJ::Request->redirect($settings_page);
         }
 
-        my $request_token = LJ::API::Twitter->fetch_request_token($public);
-        my $access_token  = LJ::API::Twitter->request_access_token(
+        my $request_token = LJ::Client::Twitter->fetch_request_token($public);
+        my $access_token  = LJ::Client::Twitter->request_access_token(
             $request_token, $verifier
         );
 
@@ -58,7 +58,7 @@
             'twitter_access_token_secret' => $access_token->{'secret'},
         );
 
-        my $userdata = LJ::API::Twitter->call(
+        my $userdata = LJ::Client::Twitter->call(
             'api_method' => 'account/verify_credentials',
             'access_token' => $access_token,
         );
@@ -69,7 +69,7 @@
         $u->set_prop( 'twitter_name' => $screen_name );
         $u->set_prop( 'twitter_link' => $profile_url );
 
-        LJ::API::Twitter->remove_request_token($public);
+        LJ::Client::Twitter->remove_request_token($public);
 
         return LJ::Request->redirect($settings_page);
     } else {

Tags: andy, bml, conf, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments