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:
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)
Message:
Fix broken posts, better permission detection, implement deletion.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Location:
perl/modules/Facebook/lib/Facebook
Files:
2 edited

Legend:

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

    r7777ac2 r5ef98c7  
    77use MIME::Base64::URLSafe;
    88use JSON;
     9with 'Facebook::Graph::Role::Uri';
    910use Facebook::Graph::AccessToken;
    1011use Facebook::Graph::Authorize;
     
    2122use Facebook::Graph::Publish::RSVPAttending;
    2223use Facebook::Graph::Publish::RSVPDeclined;
     24use URI::Encode qw(uri_decode);
     25use AnyEvent::HTTP;
    2326use Ouch;
    2427
     
    113116}
    114117
     118sub 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
    115142sub picture {
    116143    my ($self, $object_name) = @_;
  • perl/modules/Facebook/lib/Facebook/Graph/Publish.pm

    rb7fa912 r5ef98c7  
    1010use LWP::UserAgent; # XXX blegh
    1111use HTTP::Request::Common;
    12 use URI::Encode qw(uri_decode);
     12use URI::Encode qw(uri_decode uri_encode);
    1313
    1414has secret => (
     
    4747    my $uri = $self->uri;
    4848    $uri->path($self->object_name.$self->object_path);
    49     # XXX blegh
    50     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
    5151    http_post $uri->as_string, $request->content, sub {
    52         warn "whooo";
    5352        my ($response, $headers) = @_;
    5453        my %params = (
Note: See TracChangeset for help on using the changeset viewer.