Perl - Facebook Graph API

1k views Asked by At

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...

2

There are 2 answers

0
Zaikos On BEST ANSWER

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);
0
yko On

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.