Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl - Facebook Graph API

Time ago it was easy to make a distinction between desktop and web applications, but today while reading while the documentation I've noticed that this difference is less pronounced.

I'm using the Facebook::Graph module to create a desktop application, but still can not go beyond the stage of configuration. I'm stuck at authentication phase:

my $ q = Plack::Request->new($env);
$fb->request_access_token($q->query_param('code'));

(http://metacpan.org/pod/Facebook::Graph)

It keeps telling me "$ env is required". Reading the documentation I've realized that Plack is only concerned with web applications.

(http://metacpan.org/pod/Plack::Request)

Can you confirm this? If not, how do I get past this step?

It would not be a problem getting the access_token using Mechanize and then making a GET request as described in the documentation, but I do not want to complicate my existence, so if there are other ways...

like image 531
user1766178 Avatar asked Oct 22 '12 18:10

user1766178


2 Answers

A bit late, but there's a workaround.

To get an access token, take a look here:

https://developers.facebook.com/docs/howtos/login/login-for-desktop/

  1. Just create a client with Mechanize or whatever you want and login with the desidered credentials

  2. Perform the request as described

  3. Move on from the authorization page

  4. Parse the response and get the token

 $fb->access_token($token);
like image 177
Zaikos Avatar answered Sep 18 '22 15:09

Zaikos


http://developers.facebook.com/docs/reference/api/application/ says:

Note: Applications that are configured as Native/Desktop apps will not be able to make API calls that require an application access_token.

So it's not a Plack, it's Facebook who requires your app to be web. But if you may avoid access_token request, it might work.

like image 42
yko Avatar answered Sep 21 '22 15:09

yko