mauriblint
mauriblint

Reputation: 1707

Facebook Graph API: retrieve basic profile information without access_token?

Just that, I'm reading the documentation and it's seems like you can get access to the basic information without auth. But i'm getting an error

the code

$fb = new Facebook([
    'app_id' => '...',
    'app_secret' => '...',
    'default_graph_version' => 'v2.2'
]);

$response = $fb->get('/1000785'); // a valid ramdom user_id

and the response

Type: Facebook\Exceptions\FacebookSDKException
Message: You must provide an access token.
File: ...src/Facebook/FacebookRequest.php

So, should I need to implement the "classic" login anyway?

Upvotes: 0

Views: 103

Answers (1)

mauriblint
mauriblint

Reputation: 1707

Ok, just to clarify this issue. It's enough just generating an app access token.

How to generate Facebook App Access Token?

Simply, concatenating app_id and app_secret with a pipe symbol.

$appAccessToken = $config['app_id'] . '|' . $config['app_secret'];
$response = $fb->get('/0123456789', $appAccessToken);

Cheers!

Upvotes: 1

Related Questions