I want to get the each user’s FB posts by commandline.
like
These are my code.
$secret = 'xxxxx';
$key = 'xxxx';
$url = "https://graph.facebook.com/oauth/access_token?client_id="
. $key . "&client_secret=" . $secret . "&grant_type=client_credentials";
print $url. "n";
$json = json_decode(file_get_contents($url),true);
var_dump($json['access_token']); // success
$url2 = "https://graph.facebook.com/me?fields=posts&access_token=" .$json['access_token'];
$json2 = json_decode(file_get_contents($url2),true);
var_dump($json2); //
Warning: file_get_contents(https://graph.facebook.com/me?fields=posts&access_token=4887415xxxxxxxxxxxxxxx): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
I succeed to get the access_token
, however I think it is facebook app’s accesstoken?? not user’s??
I think I should indicate the who is the user before loading me?
api.
However how should I do?
I let every user login on web application AOuth and stored each users
facebook_access_token
in DataBase (but it valid a few hours????)
2
Answers
More Information: https://developers.facebook.com/docs/facebook-login/access-tokens/
grant_type=client_credentials
generates an app token.You can not use app tokens to access
me
or fetch most data about individual users.