Ignore:
Timestamp:
Sep 19, 2011, 1:31:35 PM (11 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Children:
fd92f78
Parents:
c104b43
git-author:
Edward Z. Yang <ezyang@mit.edu> (07/14/11 08:58:24)
git-committer:
Edward Z. Yang <ezyang@mit.edu> (09/19/11 13:31:35)
Message:
Fix broken posts, better permission detection, implement deletion.

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

Legend:

Unmodified
Added
Removed
  • perl/modules/Facebook/lib/BarnOwl/Module/Facebook/Handle.pm

    r9820d55 r83e90de  
    377377    my $msg = shift;
    378378
    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    };
    380384
    381385    if (defined $user) {
     
    385389        $self->{facebook}->add_post->set_message($msg)->publish($cont);
    386390    }
     391    # XXX MESSAGE PLZ
    387392}
    388393
     
    393398    my $msg = shift;
    394399
    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
    396406}
    397407
     
    438448    $self->{facebook}->access_token($self->{cfg}->{token});
    439449    # 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 {
    441452        my $result = eval { shift->as_hashref };
    442453        if ($@) {
     
    445456                . "\nand run command ':facebook-auth URL' with the URL you are redirected to.");
    446457        } 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            });
    452464        }
    453465    });
Note: See TracChangeset for help on using the changeset viewer.