Ignore:
Timestamp:
Sep 20, 2011, 11:15:32 PM (13 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Branches:
master, release-1.10, release-1.9
Children:
b7fa912
Parents:
2a42248
git-author:
Edward Z. Yang <ezyang@mit.edu> (07/12/11 09:17:04)
git-committer:
Edward Z. Yang <ezyang@mit.edu> (09/20/11 23:15:32)
Message:
Convert to async (both Facebook::Graph and us.)

Work items:
    - Documentation is all out of date
    - Think more carefully about error handling
      (right now it's delayed into the response object)
    - Really bad HTTP POST hack in Publish.pm.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Facebook/lib/Facebook/Graph/Query.pm

    r2a42248 r7777ac2  
    77use Facebook::Graph::Response;
    88with 'Facebook::Graph::Role::Uri';
    9 use LWP::UserAgent;
     9use AnyEvent::HTTP;
    1010use URI::Encode qw(uri_decode);
    1111
     
    183183
    184184sub request {
    185     my ($self, $uri) = @_;
    186     $uri ||= $self->uri_as_string;
    187     my $response = LWP::UserAgent->new->get($uri);
    188     my %params = (response => $response);
    189     if ($self->has_secret) {
    190         $params{secret} = $self->secret;
    191     }
    192     return Facebook::Graph::Response->new(%params);
     185    my ($self, $cb) = @_;
     186    my $uri = $self->uri_as_string;
     187    http_get $uri, sub {
     188        my ($response, $headers) = @_;
     189        my %params = (
     190            response => $response,
     191            headers => $headers,
     192            uri => $uri
     193        );
     194        if ($self->has_secret) {
     195            $params{secret} = $self->secret;
     196        }
     197        $cb->(Facebook::Graph::Response->new(%params));
     198    };
    193199}
    194200
Note: See TracChangeset for help on using the changeset viewer.