zrz
zrz

Reputation: 350

Facebook FQL for fetching photo

My original point was to fetch the links of every photos of a facebook photo album, so I am trying to execute this FQL query:

select link from photo where aid=xxxxxxxxxxx

I want to execute it from php so I first tried to run the Facebook FQL sample from http://developers.facebook.com/docs/reference/fql/

But I can't figure out what is this line about:

$code = $_REQUEST["code"];

When is that $_REQUEST["code"] set ?

Any other simple ideas to fetch photo links of a given photo album?

Upvotes: 2

Views: 1815

Answers (1)

Chaz
Chaz

Reputation: 3412

The $_REQUEST variable referenced in the documentation pertains to the access token that the client (the website visitor) issues to your server once they grant permission for your to app to use their information. If you are accessing publicly accessible information you'll need an "app login" access token.

You should be using the php-sdk so getting that code isn't necessary because it handles all of that for you once you initialize a facebook instance with your app secret/id.

When I did something similar I did it this way:

    require('src/facebook.php');
    $config = array(
        'appId' => 'YOURAPPID',
        'secret' => 'YOURAPPSECRET',
        'cookie' => true
    );
    $facebook = new Facebook($config);
    $query = urlencode('select link from photo where aid=xxxxxxxxxxx');
    try {
        $fbData = $facebook->api("/fql?q={$query}");
    } catch (FacebookApiException $e) {
        $fbData = $e->getResult();
    }

If you are accessing private information you'll need to follow the instructions on how to get the access token code. You can see an example of how to get that within the "example" folder of the sdk.

Upvotes: 2

Related Questions