Skip to content

Commit

Permalink
added ->request() method
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed May 13, 2013
1 parent f97bda2 commit a61a688
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.0600 2013-05-13
- Added the $fb->request() method.

1.0502 2013-05-07
- Added AnyEvent::TLS as a prereq. Should get rid of the CPAN complaints about not having TLS.

Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author = JT Smith <jt@plainblack.com>
license = Perl_5
copyright_holder = Plain Black Corporation
copyright_year = 2013
version = 1.0502
version = 1.0600

[@Classic]

Expand Down
18 changes: 14 additions & 4 deletions lib/Facebook/Graph.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use Facebook::Graph::AccessToken;
use Facebook::Graph::Authorize;
use Facebook::Graph::Query;
use Facebook::Graph::Picture;
use Facebook::Graph::Request;
use Facebook::Graph::Publish::Post;
use Facebook::Graph::Publish::Photo;
use Facebook::Graph::Publish::Checkin;
Expand Down Expand Up @@ -99,6 +100,11 @@ sub fql {
return $self->query->find('fql')->search($query)->request->as_hashref;
}

sub request {
my ($self, $uri) = @_;
return Facebook::Graph::Request->new->get($uri)->recv;
}

sub query {
my ($self) = @_;
my %params = ( );
Expand Down Expand Up @@ -311,10 +317,7 @@ You can also do asynchronous calls like this:
Or fetching a response from a URI you already have:
my $hashref = $fb->query
->request('https://graph.facebook.com/btaylor')
->as_hashref;
my $hashref = $fb->request('https://graph.facebook.com/btaylor')->as_hashref;
=head2 Building A Privileged App
Expand Down Expand Up @@ -409,6 +412,13 @@ An authorization code string that you should have gotten by going through the C<
Creates a L<Facebook::Graph::Query> object, which can be used to fetch and search data from Facebook.
=head2 request ( uri )
Fetch a Facebook::Graph URI you already have.
=head3 uri
The URI to fetch. For example: https://graph.facebook.com/amazon
=head2 fetch ( id )
Expand Down
4 changes: 3 additions & 1 deletion t/03_public_query.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 12;
use Test::More tests => 13;
use lib '../lib';
use Ouch;

Expand Down Expand Up @@ -29,3 +29,5 @@ eval { $fb->query->select_fields('')->request->as_json };
is($@->code, 400, 'exception inherits http status code');
is($@->message, 'Could not execute request (https://graph.facebook.com?fields=): GraphMethodException - Unsupported get request.', 'exception gives good detail');

is $fb->request('https://graph.facebook.com/amazon')->as_hashref->{username}, 'Amazon', 'can directly fetch a facebook graph url' ;

0 comments on commit a61a688

Please sign in to comment.