| 1 | package Net::Facebook::Oauth2; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use URI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | BEGIN { | ||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | my @time = localtime; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | if ($time[5] >= 118 && $time[4] > 8) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$time[5] >= 118 and $time[4] > 8
MC/DC0%0/2
$time[5] >= 118 and $time[4] > 8
$time[5] >= 118
$time[4] > 8
Truth table33%1/3
A and B
A= $time[5] >= 118B= $time[4] > 8
| |||||||||||||||||||||||||||||||||
| 14 | 0 | warn "\n****************************************************************************\n" | |||||||||||||||||||||||||||||||
| 15 | . "[WARNING] This version of Net::Facebook::Oauth2 uses Facebook Graph API v2.8\n" | ||||||||||||||||||||||||||||||||
| 16 | . "which is SCHEDULED FOR DEPRECATION on 5 October 2018. If this module\n" | ||||||||||||||||||||||||||||||||
| 17 | . "(together with any associated code) is not updated, it may stop working!\n" | ||||||||||||||||||||||||||||||||
| 18 | . "****************************************************************************\n" | ||||||||||||||||||||||||||||||||
| 19 | ; | ||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use constant ACCESS_TOKEN_URL => 'https://graph.facebook.com/v2.8/oauth/access_token'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant AUTHORIZE_URL => 'https://www.facebook.com/v2.8/dialog/oauth'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 2 | our $VERSION = '0.10'; | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | sub new { | ||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | my ($class,%options) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 7 | my $self = {}; | |||||||||||||||||||||||||||||||
| 31 | 7 | $self->{options} = \%options; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | if (!$options{access_token}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | croak "You must provide your application id in new()\nNet::Facebook::Oauth2->new( application_id => '...' )" unless defined $self->{options}->{application_id}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | croak "You must provide your application secret in new()\nNet::Facebook::Oauth2->new( application_secret => '...' )" unless defined $self->{options}->{application_secret}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | $self->{browser} = $options{browser} || LWP::UserAgent->new; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$options{'browser'} || 'LWP::UserAgent'->new
MC/DC0%0/2
$options{'browser'} || 'LWP::UserAgent'->new
$options{'browser'}
'LWP::UserAgent'->new
Truth table66%2/3
A || B
A= $options{'browser'}B= 'LWP::UserAgent'->new
| |||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | $self->{access_token_url} = $options{access_token_url} || ACCESS_TOKEN_URL; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{'access_token_url'} || 'https://graph.facebook.com/v2.8/oauth/access_token'
MC/DC0%0/1
$options{'access_token_url'} || 'https://graph.facebook.com/v2.8/oauth/access_token'
$options{'access_token_url'}
Truth table50%1/2
A
A= $options{'access_token_url'}
| |||||||||||||||||||||||||||||||||
| 40 | 5 | ▶ | $self->{authorize_url} = $options{authorize_url} || AUTHORIZE_URL; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{'authorize_url'} || 'https://www.facebook.com/v2.8/dialog/oauth'
MC/DC0%0/1
$options{'authorize_url'} || 'https://www.facebook.com/v2.8/dialog/oauth'
$options{'authorize_url'}
Truth table50%1/2
A
A= $options{'authorize_url'}
| |||||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | $self->{display} = $options{display} || 'page'; ## other values popup and wab | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{'display'} || 'page'
MC/DC0%0/1
$options{'display'} || 'page'
$options{'display'}
Truth table50%1/2
A
A= $options{'display'}
| |||||||||||||||||||||||||||||||||
| 42 | 5 | $self->{access_token} = $options{access_token}; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 5 | return bless($self, $class); | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | sub get_authorization_url { | ||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my ($self,%params) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
get_authorization_url: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $params{callback} ||= $self->{options}->{callback}; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$params{"callback"} ||= $self->{"options"}{"callback"}
MC/DC0%0/2
$params{"callback"} ||= $self->{"options"}{"callback"}
$params{"callback"}
$self->{"options"}{"callback"}
Truth table0%0/3
A ||= B
A= $params{"callback"}B= $self->{"options"}{"callback"}
| |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | croak "You must pass a callback parameter with Oauth v2.0" unless defined $params{callback}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $params{display} = $self->{display} unless defined $params{display}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{options}->{callback} = $params{callback}; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | my $url = $self->{authorize_url} | ||||||||||||||||||||||||||||||||
| 57 | ."?client_id=" | ||||||||||||||||||||||||||||||||
| 58 | .uri_escape($self->{options}->{application_id}) | ||||||||||||||||||||||||||||||||
| 59 | ."&redirect_uri=" | ||||||||||||||||||||||||||||||||
| 60 | 0 | .uri_escape($params{callback}); | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ($params{scope}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 0 | my $scope = join(',', @{$params{scope}}); | |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $url .= '&scope=' . $scope if $scope; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $url .= '&state=' . $params{state} if $params{state}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $url .= '&response_type=' . $params{response_type} if $params{response_type}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $url .= '&auth_type=' . $params{auth_type} if $params{auth_type}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 0 | $url .= "&display=".$params{display}; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | return $url; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | sub get_access_token { | ||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($self,%params) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
get_access_token: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $params{callback} ||= $self->{options}->{callback}; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$params{"callback"} ||= $self->{"options"}{"callback"}
MC/DC0%0/2
$params{"callback"} ||= $self->{"options"}{"callback"}
$params{"callback"}
$self->{"options"}{"callback"}
Truth table0%0/3
A ||= B
A= $params{"callback"}B= $self->{"options"}{"callback"}
| |||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $params{code} ||= $self->{options}->{code}; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$params{"code"} ||= $self->{"options"}{"code"}
MC/DC0%0/2
$params{"code"} ||= $self->{"options"}{"code"}
$params{"code"}
$self->{"options"}{"code"}
Truth table0%0/3
A ||= B
A= $params{"code"}B= $self->{"options"}{"code"}
| |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | croak "You must pass a code parameter with Oauth v2.0" unless defined $params{code}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | croak "You must pass callback URL" unless defined $params{callback}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | 0 | $self->{options}->{code} = $params{code}; | |||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | ###generating access token URL | ||||||||||||||||||||||||||||||||
| 86 | my $getURL = $self->{access_token_url} | ||||||||||||||||||||||||||||||||
| 87 | ."?client_id=" | ||||||||||||||||||||||||||||||||
| 88 | .uri_escape($self->{options}->{application_id}) | ||||||||||||||||||||||||||||||||
| 89 | ."&redirect_uri=" | ||||||||||||||||||||||||||||||||
| 90 | .uri_escape($params{callback}) | ||||||||||||||||||||||||||||||||
| 91 | ."&client_secret=" | ||||||||||||||||||||||||||||||||
| 92 | .uri_escape($self->{options}->{application_secret}) | ||||||||||||||||||||||||||||||||
| 93 | 0 | ."&code=$params{code}"; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 0 | my $response = $self->{browser}->get($getURL); | |||||||||||||||||||||||||||||||
| 96 | 0 | my $json = decode_json($response->content()); | |||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (!$response->is_success || exists $json->{error}){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $response->is_success or exists $json->{"error"}
MC/DC0%0/2
not $response->is_success or exists $json->{"error"}
not $response->is_success
exists $json->{"error"}
Truth table0%0/3
not(A) or B
A= not $response->is_successB= exists $json->{"error"}
| |||||||||||||||||||||||||||||||||
| 99 | ##got an error response from facebook. die and display error message | ||||||||||||||||||||||||||||||||
| 100 | 0 | croak "'" . $json->{error}->{type}. "'" . " " .$json->{error}->{message}; | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | elsif ($json->{access_token}) { | ||||||||||||||||||||||||||||||||
| 103 | ##everything is ok proccess response and extract access token | ||||||||||||||||||||||||||||||||
| 104 | 0 | return $self->{access_token} = $json->{access_token}; | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||
| 107 | 0 | croak "can't get access token from " . $response->content(); | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | sub get { | ||||||||||||||||||||||||||||||||
| 112 | 7 | ▶ | my ($self,$url,$params) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 113 | 7 | ▶ | unless ($self->_has_access_token($url)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | 5 | ▶ | croak "You must pass access_token" unless defined $self->{access_token}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 5 | ▶ | $url .= $self->{_has_query} ? '&' : '?'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | 5 | $url .= "access_token=" . $self->{access_token}; | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | ##construct the new url | ||||||||||||||||||||||||||||||||
| 120 | 7 | my @array; | |||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 7 | ▶ | while ( my ($key, $value) = each(%{$params})){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | 5 | $value = uri_escape($value); | |||||||||||||||||||||||||||||||
| 124 | 5 | push(@array, "$key=$value"); | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 7 | my $string = join('&', @array); | |||||||||||||||||||||||||||||||
| 128 | 7 | ▶ | $url .= "&".$string if $string; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 7 | my $response = $self->{browser}->get($url); | |||||||||||||||||||||||||||||||
| 131 | 7 | my $content = $response->content(); | |||||||||||||||||||||||||||||||
| 132 | 7 | return $self->_content($content); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | sub post { | ||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | my ($self,$url,$params) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
post: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | unless ($self->_has_access_token($url)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | croak "You must pass access_token" unless defined $self->{access_token}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 1 | $params->{access_token} = $self->{access_token}; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | 2 | my $response = $self->{browser}->post($url,$params); | |||||||||||||||||||||||||||||||
| 142 | 2 | my $content = $response->content(); | |||||||||||||||||||||||||||||||
| 143 | 2 | return $self->_content($content); | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | sub delete { | ||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | my ($self,$url,$params) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | unless ($self->_has_access_token($url)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | croak "You must pass access_token" unless defined $self->{access_token}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 1 | $params->{access_token} = $self->{access_token}; | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | 1 | my $response = $self->{browser}->delete($url,$params); | |||||||||||||||||||||||||||||||
| 153 | 1 | my $content = $response->content(); | |||||||||||||||||||||||||||||||
| 154 | 1 | return $self->_content($content); | |||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | sub as_hash { | ||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 159 | 0 | return decode_json($self->{content}); | |||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | sub as_json { | ||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
as_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 164 | 3 | return $self->{content}; | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | sub _content { | ||||||||||||||||||||||||||||||||
| 168 | 10 | ▶ | my ($self,$content) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_content: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 169 | 10 | $self->{content} = $content; | |||||||||||||||||||||||||||||||
| 170 | 10 | return $self; | |||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | sub _has_access_token { | ||||||||||||||||||||||||||||||||
| 174 | 10 | ▶ | my ($self, $url) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_has_access_token: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 175 | 10 | my $uri = URI->new($url); | |||||||||||||||||||||||||||||||
| 176 | 10 | my %q = $uri->query_form; | |||||||||||||||||||||||||||||||
| 177 | #also check if we have a query and save result | ||||||||||||||||||||||||||||||||
| 178 | 10 | $self->{_has_query} = $uri->query(); | |||||||||||||||||||||||||||||||
| 179 | 10 | ▶ | if (grep { $_ eq 'access_token' } keys %q) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | 3 | return 1; | |||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | 7 | return; | |||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | 2 | 1; | |||||||||||||||||||||||||||||||
| 186 | __END__ | ||||||||||||||||||||||||||||||||
| 187 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | Net::Facebook::Oauth2 - a simple Perl wrapper around Facebook OAuth v2.0 protocol | ||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | =for html | ||||||||||||||||||||||||||||||||
| 192 | <a href="https://travis-ci.org/mamod/Net-Facebook-Oauth2"><img src="https://travis-ci.org/mamod/Net-Facebook-Oauth2.svg?branch=master"></a> | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | =head1 FACEBOOK GRAPH API VERSION | ||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | This module complies to Facebook Graph API version 2.8, the latest | ||||||||||||||||||||||||||||||||
| 197 | at the time of publication, B<< scheduled for deprecation on October 5th, 2018 >>. | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | One month prior to that, using this version of Net::Facebook::Oauth2 will | ||||||||||||||||||||||||||||||||
| 200 | trigger a warning message. | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | Somewhere in your application's login process: | ||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | use Net::Facebook::Oauth2; | ||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||
| 208 | my $fb = Net::Facebook::Oauth2->new( | ||||||||||||||||||||||||||||||||
| 209 | application_id => 'your_application_id', | ||||||||||||||||||||||||||||||||
| 210 | application_secret => 'your_application_secret', | ||||||||||||||||||||||||||||||||
| 211 | callback => 'http://yourdomain.com/facebook/callback' | ||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||
| 214 | # get the authorization URL for your application | ||||||||||||||||||||||||||||||||
| 215 | my $url = $fb->get_authorization_url( | ||||||||||||||||||||||||||||||||
| 216 | scope => [ 'public_profile', 'email', 'user_about_me', 'manage_pages' ], | ||||||||||||||||||||||||||||||||
| 217 | display => 'page' | ||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | Now redirect the user to this C<$url>. | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | Once the user authorizes your application, Facebook will send him/her back | ||||||||||||||||||||||||||||||||
| 223 | to your application, on the C<callback> link provided above. PLEASE NOTE | ||||||||||||||||||||||||||||||||
| 224 | THAT YOU MUST PRE-AUTHORIZE YOUR CALLBACK URI ON FACEBOOK'S APP DASHBOARD. | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | Inside that callback route, use the verifier code parameter that Facebook | ||||||||||||||||||||||||||||||||
| 227 | sends to get the access token: | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | # param() below is a bogus function. Use whatever your web framework | ||||||||||||||||||||||||||||||||
| 230 | # provides (e.g. $c->req->param('code'), $cgi->param('code'), etc) | ||||||||||||||||||||||||||||||||
| 231 | my $code = param('code'); | ||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | my $access_token = $fb->get_access_token(code => $code); | ||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | If you got so far, your user is logged! Save this access token in your | ||||||||||||||||||||||||||||||||
| 236 | database or session. | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | Later on you can use that access token to communicate with Facebook on behalf | ||||||||||||||||||||||||||||||||
| 239 | of this user: | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | my $fb = Net::Facebook::Oauth2->new( | ||||||||||||||||||||||||||||||||
| 242 | access_token => $access_token | ||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | my $info = $fb->get( | ||||||||||||||||||||||||||||||||
| 246 | 'https://graph.facebook.com/v2.8/me' # Facebook API URL | ||||||||||||||||||||||||||||||||
| 247 | ); | ||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | print $info->as_json; | ||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||
| 253 | Net::Facebook::Oauth2 gives you a way to simply access FaceBook Oauth 2.0 protocol | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | For more information please see example folder shipped with this Module | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | For more information about Facebook Oauth 2.0 API | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | Please Check | ||||||||||||||||||||||||||||||||
| 262 | L<http://developers.facebook.com/docs/> | ||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | get/post Facebook Graph API | ||||||||||||||||||||||||||||||||
| 265 | L<http://developers.facebook.com/docs/api> | ||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | =head1 USAGE | ||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | =head2 C<Net::Facebook::Oauth-E<gt>new( %args )> | ||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | Returns a new object to handle user authentication. | ||||||||||||||||||||||||||||||||
| 272 | Pass arguments as a hash. The following arguments are I<REQUIRED> | ||||||||||||||||||||||||||||||||
| 273 | unless you're passing an access_token (see optional arguments below): | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | =over 4 | ||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | =item * C<application_id> | ||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | Your application id as you get from facebook developers platform | ||||||||||||||||||||||||||||||||
| 280 | when you register your application | ||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | =item * C<application_secret> | ||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||
| 284 | Your application secret id as you get from facebook developers platform | ||||||||||||||||||||||||||||||||
| 285 | when you register your application | ||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | =back | ||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | The following arguments are I<OPTIONAL>: | ||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||
| 291 | =over 4 | ||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | =item * C<access_token> | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | If you want to instantiate an object to an existing access token, you may | ||||||||||||||||||||||||||||||||
| 296 | do so by passing it to this argument. | ||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||
| 298 | =item * C<browser> | ||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||
| 300 | The user agent that will handle requests to Facebook's API. Defaults to | ||||||||||||||||||||||||||||||||
| 301 | LWP::UserAgent, but can be any method that implements the methods C<get>, | ||||||||||||||||||||||||||||||||
| 302 | C<post> and C<delete> and whose response to such methods implements | ||||||||||||||||||||||||||||||||
| 303 | C<is_success> and C<content>. | ||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | =item * C<display> | ||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | See C<display> under the C<get_authorization_url> method below. | ||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | =item * C<authorize_url> | ||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | Overrides the default (2.8) API endpoint for Facebook's oauth. | ||||||||||||||||||||||||||||||||
| 312 | Used mostly for testing new versions. | ||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||
| 314 | =item * C<access_token_url> | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | Overrides the default (2.8) API endpoint for Facebook's access token. | ||||||||||||||||||||||||||||||||
| 317 | Used mostly for testing new versions. | ||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | =item * C<auth_type> | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | When a user declines a given permission, you must reauthorize them. But when | ||||||||||||||||||||||||||||||||
| 322 | you do so, any previously declined permissions will not be asked again by | ||||||||||||||||||||||||||||||||
| 323 | Facebook. Set this argument to C<'rerequest'> to explicitly tell the dialog | ||||||||||||||||||||||||||||||||
| 324 | you're re-asking for a declined permission. | ||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | =back | ||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | =head2 C<$fb-E<gt>get_authorization_url( %args )> | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | Returns an authorization URL for your application. Once you receive this | ||||||||||||||||||||||||||||||||
| 331 | URL, redirect your user there in order to authorize your application. | ||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||
| 333 | The following argument is I<REQUIRED>: | ||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||
| 335 | =over 4 | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | =item * C<callback> | ||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | callback => 'http://example.com/login/facebook/success' | ||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||
| 341 | The callback URL, where Facebook will send users after they authorize | ||||||||||||||||||||||||||||||||
| 342 | your application. YOU MUST CONFIRM THIS URL ON FACEBOOK'S APP DASHBOARD. | ||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | To do that, go to the App Dashboard, click Facebook Login in the right-hand | ||||||||||||||||||||||||||||||||
| 345 | menu, and check the B<Valid OAuth redirect URIs> in the Client OAuth Settings | ||||||||||||||||||||||||||||||||
| 346 | section. | ||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||
| 348 | =back | ||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||
| 350 | This method also accepts the following I<OPTIONAL> arguments: | ||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | =over 4 | ||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||
| 354 | =item * C<scope> | ||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||
| 356 | scope => ['user_events','manage_pages', ...] | ||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||
| 358 | Array of Extended permissions as described by facebook Oauth API. | ||||||||||||||||||||||||||||||||
| 359 | You can get more information about scope/Extended Permission from | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | L<https://developers.facebook.com/docs/facebook-login/permissions/> | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | Please note that requesting information other than C<public_profile>, | ||||||||||||||||||||||||||||||||
| 364 | C<email> and C<user_friends> B<will require your app to be reviewed by Facebook!> | ||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | =item * C<state> | ||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | state => '123456abcde' | ||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | An arbitrary unique string provided by you to guard against Cross-site Request Forgery. | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | =item * C<display> | ||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | display => 'page' | ||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||
| 376 | How to display Facebook Authorization page. Defaults to C<page>. | ||||||||||||||||||||||||||||||||
| 377 | Can be any of the following: | ||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | =over 4 | ||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||
| 381 | =item * C<page> | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | This will display facebook authorization page as full page | ||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | =item * C<popup> | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | This option is useful if you want to popup authorization page | ||||||||||||||||||||||||||||||||
| 388 | as this option tell facebook to reduce the size of the authorization page | ||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||
| 390 | =item * C<wab> | ||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||
| 392 | From the name, for wab and mobile applications this option is the best | ||||||||||||||||||||||||||||||||
| 393 | facebook authorization page will fit there :) | ||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | =back | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | =item * C<response_type> | ||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||
| 399 | response_type => 'code' | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | When the redirect back to the app occurs, determines whether the response | ||||||||||||||||||||||||||||||||
| 402 | data is in URL parameters or fragments. Defaults to C<code>, which is | ||||||||||||||||||||||||||||||||
| 403 | Facebook's default and useful for cases where the server handles the token | ||||||||||||||||||||||||||||||||
| 404 | (which is most likely why you are using this module), but can be also be | ||||||||||||||||||||||||||||||||
| 405 | C<token>, C<code%20token>, or C<granted_scopes>. Please see | ||||||||||||||||||||||||||||||||
| 406 | L<< Facebook's login documentation|https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow >> | ||||||||||||||||||||||||||||||||
| 407 | for more information. | ||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | =back | ||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | =head2 C<$fb-E<gt>get_access_token( %args )> | ||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||
| 413 | This method issues a GET request to Facebook's API to retrieve the | ||||||||||||||||||||||||||||||||
| 414 | access token string for the specified code (passed as an argument). | ||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | Returns the access token string or raises an exception in case of errors. | ||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | You should call this method inside the route for the callback URI defined | ||||||||||||||||||||||||||||||||
| 419 | in the C<get_authorization_url> method. It receives the following arguments: | ||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | =over 4 | ||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | =item * C<code> | ||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||
| 425 | This is the verifier code that Facebook sends back to your | ||||||||||||||||||||||||||||||||
| 426 | callback URL once user authorize your app, you need to capture | ||||||||||||||||||||||||||||||||
| 427 | this code and pass to this method in order to get the access token. | ||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||
| 429 | Verifier code will be presented with your callback URL as code | ||||||||||||||||||||||||||||||||
| 430 | parameter as the following: | ||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||
| 432 | http://your-call-back-url.com?code=234er7y6fdgjdssgfsd... | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | Note that if you have fiddled with the C<response_type> argument, | ||||||||||||||||||||||||||||||||
| 435 | you might not get this parameter properly. | ||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||
| 437 | =back | ||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||
| 439 | When the access token is returned you need to save it in a secure | ||||||||||||||||||||||||||||||||
| 440 | place in order to use it later in your application. The token indicates | ||||||||||||||||||||||||||||||||
| 441 | that a user has authorized your site/app, meaning you can associate that | ||||||||||||||||||||||||||||||||
| 442 | token to that user and issue API requests to Facebook on their behalf. | ||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | To know I<WHICH> user has granted you the authorization (e.g. when building | ||||||||||||||||||||||||||||||||
| 445 | a login system to associate that token with a unique user on your database), | ||||||||||||||||||||||||||||||||
| 446 | you must make a request to fetch Facebook's own unique identifier for that | ||||||||||||||||||||||||||||||||
| 447 | user, and then associate your own user's unique id to Facebook's. This is | ||||||||||||||||||||||||||||||||
| 448 | usually done by making a GET request to the C<me> API endpoint, as shown | ||||||||||||||||||||||||||||||||
| 449 | in the SYNOPSIS. | ||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | B<IMPORTANT:> Expect that the length of all access token types will change | ||||||||||||||||||||||||||||||||
| 452 | over time as Facebook makes changes to what is stored in them and how they | ||||||||||||||||||||||||||||||||
| 453 | are encoded. You can expect that they will grow and shrink over time. | ||||||||||||||||||||||||||||||||
| 454 | Please use a variable length data type without a specific maximum size to | ||||||||||||||||||||||||||||||||
| 455 | store access tokens. | ||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||
| 457 | =head2 C<$fb-E<gt>get( $url, $args )> | ||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||
| 459 | Sends a GET request to Facebook and stores the response in the given object. | ||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||
| 461 | =over 4 | ||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | =item * C<url> | ||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||
| 465 | Facebook Graph API URL as string. You must provide the full URL. | ||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | =item * C<$args> | ||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | hashref of parameters to be sent with graph API URL if required. | ||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | =back | ||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||
| 473 | You can access the response using the following methods: | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | =over 4 | ||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||
| 477 | =item * C<$responseE<gt>as_json> | ||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||
| 479 | Returns response as json object | ||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||
| 481 | =item * C<$responseE<gt>as_hash> | ||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||
| 483 | Returns response as perl hashref | ||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||
| 485 | =back | ||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | For more information about facebook graph API, please check | ||||||||||||||||||||||||||||||||
| 488 | http://developers.facebook.com/docs/api | ||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||
| 490 | =head2 C<$fb-E<gt>post( $url, $args )> | ||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||
| 492 | Send a POST request to Facebook and stores the response in the given object. | ||||||||||||||||||||||||||||||||
| 493 | See the C<as_hash> and C<as_json> methods above for how to retrieve the | ||||||||||||||||||||||||||||||||
| 494 | response. | ||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | =over 4 | ||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||
| 498 | =item * C<url> | ||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||
| 500 | Facebook Graph API URL as string | ||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||
| 502 | =item * C<$args> | ||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||
| 504 | hashref of parameters to be sent with graph API URL | ||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||
| 506 | =back | ||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||
| 508 | For more information about facebook graph API, please check | ||||||||||||||||||||||||||||||||
| 509 | L<http://developers.facebook.com/docs/api> | ||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||
| 511 | =head2 C<$fb-E<gt>delete( $url, $args )> | ||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||
| 513 | Send a DELETE request to Facebook and stores the response in the given object. | ||||||||||||||||||||||||||||||||
| 514 | See the C<as_hash> and C<as_json> methods above for how to retrieve the | ||||||||||||||||||||||||||||||||
| 515 | response. | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | =over 4 | ||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||
| 519 | =item * C<url> | ||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | Facebook Graph API URL as string | ||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||
| 523 | =item * C<$args> | ||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||
| 525 | hashref of parameters to be sent with graph API URL | ||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||
| 528 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||
| 530 | Mahmoud A. Mehyar, E<lt>mamod.mehyar@gmail.comE<gt> | ||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||
| 532 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||
| 534 | Big Thanks To | ||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||
| 536 | =over 4 | ||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||
| 538 | =item * Takatsugu Shigeta L<@comewalk|https://github.com/comewalk> | ||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||
| 540 | =item * Breno G. de Oliveira L<@garu|https://github.com/garu> | ||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | =item * squinker L<@squinker|https://github.com/squinker> | ||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||
| 544 | =item * Valcho Nedelchev L<@valchonedelchev|https://github.com/valchonedelchev> | ||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | =back | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||
| 550 | Copyright (C) 2012-2016 by Mahmoud A. Mehyar | ||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||
| 553 | it under the same terms as Perl itself, either Perl version 5.10.1 or, | ||||||||||||||||||||||||||||||||
| 554 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||
| 556 | =cut | ||||||||||||||||||||||||||||||||