0

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?

mauriblint
  • 1,802
  • 2
  • 29
  • 46
  • How did you get the user_id? – WizKid Dec 15 '16 at 18:59
  • it's a random number between a "valid range", i mean, with an access_token I can retrieve the information, it's a valid id. – mauriblint Dec 15 '16 at 19:19
  • Apps are using app scoped user IDs. Just because a User ID is valid in one app doesn't mean it will be valid in a different app. – WizKid Dec 15 '16 at 19:20
  • 1
    There might be ways but it would depend on what you want to get from the user. For exemple a app token might work. – Mathieu de Lorimier Dec 15 '16 at 19:30
  • great!! @MathieudeLorimier i'm just google for app token i make it work, thanks again. http://stackoverflow.com/questions/12948809/trying-to-get-app-access-token – mauriblint Dec 15 '16 at 20:26
  • _"So, should I need to implement the "classic" login anyway?"_ - yes, because unless users actively decide to share their data with your app, it is none of your business. – CBroe Dec 15 '16 at 21:26

1 Answers1

1

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!

mauriblint
  • 1,802
  • 2
  • 29
  • 46