Changeset 5ef98c7
- Timestamp:
- Sep 20, 2011, 11:15:32 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.9
- Children:
- 68c0afd
- Parents:
- b7fa912
- git-author:
- Edward Z. Yang <ezyang@mit.edu> (07/14/11 08:58:24)
- git-committer:
- Edward Z. Yang <ezyang@mit.edu> (09/20/11 23:15:32)
- Location:
- perl/modules/Facebook/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Facebook/lib/BarnOwl/Module/Facebook/Handle.pm
r7777ac2 r5ef98c7 377 377 my $msg = shift; 378 378 379 my $cont = sub { $self->sleep(0); }; 379 my $cont = sub { 380 eval { shift->as_hashref }; 381 return unless $self->check_result; 382 $self->sleep(0); 383 }; 380 384 381 385 if (defined $user) { … … 385 389 $self->{facebook}->add_post->set_message($msg)->publish($cont); 386 390 } 391 # XXX MESSAGE PLZ 387 392 } 388 393 … … 393 398 my $msg = shift; 394 399 395 $self->{facebook}->add_comment($post_id)->set_message($msg)->publish(sub { $self->sleep(0); }); 400 $self->{facebook}->add_comment($post_id)->set_message($msg)->publish(sub { 401 eval { shift->as_hashref }; 402 return unless $self->check_result; 403 $self->sleep(0); 404 }); 405 # XXX MESSAGE PLZ 396 406 } 397 407 … … 438 448 $self->{facebook}->access_token($self->{cfg}->{token}); 439 449 # Do a quick check to see if things are working 440 $self->{facebook}->query()->find('me')->select_fields('name')->request(sub { 450 #$self->{facebook}->query()->find('me')->select_fields('name')->request(sub { 451 $self->{facebook}->add_post->set_message("Logged in to BarnOwl at " . localtime time)->set_privacy('CUSTOM', {friends => 'SELF'})->publish(sub { 441 452 my $result = eval { shift->as_hashref }; 442 453 if ($@) { … … 445 456 . "\nand run command ':facebook-auth URL' with the URL you are redirected to."); 446 457 } else { 447 my $name = $result->{'name'}; 448 BarnOwl::admin_message('Facebook', "Successfully logged in to Facebook as $name!"); 449 $self->{logged_in} = 1; 450 $self->sleep(0); # start polling 451 $success->(); 458 $self->{facebook}->delete($result->{id}, sub { 459 BarnOwl::admin_message('Facebook', "Successfully logged in to Facebook."); 460 $self->{logged_in} = 1; 461 $self->sleep(0); # start polling 462 $success->(); 463 }); 452 464 } 453 465 }); -
perl/modules/Facebook/lib/Facebook/Graph.pm
r7777ac2 r5ef98c7 7 7 use MIME::Base64::URLSafe; 8 8 use JSON; 9 with 'Facebook::Graph::Role::Uri'; 9 10 use Facebook::Graph::AccessToken; 10 11 use Facebook::Graph::Authorize; … … 21 22 use Facebook::Graph::Publish::RSVPAttending; 22 23 use Facebook::Graph::Publish::RSVPDeclined; 24 use URI::Encode qw(uri_decode); 25 use AnyEvent::HTTP; 23 26 use Ouch; 24 27 … … 113 116 } 114 117 118 sub delete { 119 my ($self, $id, $cb) = @_; 120 my %query; 121 if ($self->has_access_token) { 122 $query{access_token} = uri_decode($self->access_token); 123 } 124 my $uri = $self->uri; 125 $uri->path($id); 126 $uri->query_form(%query); 127 http_request(DELETE => $uri->as_string, sub { 128 my ($response, $headers) = @_; 129 my %params = ( 130 response => $response, 131 headers => $headers, 132 uri => $uri 133 ); 134 if ($self->has_secret) { 135 $params{secret} = $self->secret; 136 } 137 $cb->(Facebook::Graph::Response->new(%params)); 138 }); 139 () # return nothing 140 } 141 115 142 sub picture { 116 143 my ($self, $object_name) = @_; -
perl/modules/Facebook/lib/Facebook/Graph/Publish.pm
rb7fa912 r5ef98c7 10 10 use LWP::UserAgent; # XXX blegh 11 11 use HTTP::Request::Common; 12 use URI::Encode qw(uri_decode );12 use URI::Encode qw(uri_decode uri_encode); 13 13 14 14 has secret => ( … … 47 47 my $uri = $self->uri; 48 48 $uri->path($self->object_name.$self->object_path); 49 # XXX blegh50 my $request = LWP::UserAgent->new->request(POST $uri->as_string, $self->get_post_params);49 my $request = POST($uri->as_string,$self->get_post_params); 50 # XXX Do this more elegantly 51 51 http_post $uri->as_string, $request->content, sub { 52 warn "whooo";53 52 my ($response, $headers) = @_; 54 53 my %params = (
Note: See TracChangeset
for help on using the changeset viewer.