| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # ABSTRACT: Simple interface for making FQL requests. | 
| 2 |  |  |  |  |  |  | package WWW::Facebook::FQL::Simple; | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 39232 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 6 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 1136 | use JSON; | 
|  | 1 |  |  |  |  | 18138 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 9 | 1 |  |  | 1 |  | 1266 | use LWP::UserAgent; | 
|  | 1 |  |  |  |  | 61414 |  | 
|  | 1 |  |  |  |  | 43 |  | 
| 10 | 1 |  |  | 1 |  | 993 | use URI::Encode qw( uri_encode ); | 
|  | 1 |  |  |  |  | 15498 |  | 
|  | 1 |  |  |  |  | 71 |  | 
| 11 | 1 |  |  | 1 |  | 8 | use Carp qw/croak/; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 352 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | my $API_BASE = 'http://api.facebook.com/method/fql.query?format=json&query='; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub query { | 
| 17 | 0 |  |  | 0 | 1 |  | my $class = shift; | 
| 18 | 0 |  |  |  |  |  | my $args  = shift; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 0 |  |  |  |  |  | my $ua = LWP::UserAgent->new; | 
| 21 | 0 |  |  |  |  |  | $ua->timeout(10); | 
| 22 | 0 |  |  |  |  |  | $ua->env_proxy; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 0 |  |  |  |  |  | my $response = $ua->get( uri_encode( $API_BASE . $args->{query} ) ); | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 0 | 0 |  |  |  |  | if ( $response->is_success ) { | 
| 27 | 0 |  |  |  |  |  | return decode_json $response->content; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  | else { | 
| 30 | 0 |  |  |  |  |  | croak $response->status_line; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | 1; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | __END__ |