Ignore:
Timestamp:
Sep 20, 2011, 11:15:32 PM (11 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Branches:
master, 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.pm

    r2a42248 r7777ac2  
    6262
    6363sub request_access_token {
    64     my ($self, $code) = @_;
    65     my $token = Facebook::Graph::AccessToken->new(
     64    my ($self, $code, $cb) = @_;
     65    Facebook::Graph::AccessToken->new(
    6666        code            => $code,
    6767        postback        => $self->postback,
    6868        secret          => $self->secret,
    6969        app_id          => $self->app_id,
    70     )->request;
    71     $self->access_token($token->token);
    72     return $token;
     70    )->request(sub {
     71        my ($response) = @_;
     72        $self->access_token($response->token);
     73        $cb->($response);
     74    });
    7375}
    7476
    7577sub convert_sessions {
    76     my ($self, $sessions) = @_;
    77     return Facebook::Graph::Session->new(
     78    my ($self, $sessions, $cb) = @_;
     79    Facebook::Graph::Session->new(
    7880        secret          => $self->secret,
    7981        app_id          => $self->app_id,
    8082        sessions        => $sessions,
    81         )
    82         ->request
    83         ->as_hashref;
     83    )->request($cb); # API change
    8484}
    8585
     
    9292}
    9393
    94 sub fetch {
    95     my ($self, $object_name) = @_;
    96     return $self->query->find($object_name)->request->as_hashref;
    97 }
     94# XXX error handling
     95#sub fetch {
     96#    my ($self, $object_name, $cb) = @_;
     97#    $self->query->find($object_name)->request(sub {
     98#        my ($result) = @_;
     99#        $cb->($result->as_hashref);
     100#    });
     101#}
    98102
    99103sub query {
     
    540544L<Any::Moose>
    541545L<JSON>
    542 L<LWP>
    543 L<LWP::Protocol::https>
     546L<AnyEvent::HTTP>
    544547L<Mozilla::CA>
    545548L<URI>
Note: See TracChangeset for help on using the changeset viewer.