m1alesis
m1alesis

Reputation: 700

Facebook Graph private profile picture

So I am trying to create a register from facebook script and I am testing with my own Facebook account.

This is what I am doing:-

I am hitting this link to get access token:-

https://www.facebook.com/dialog/oauth?client_id=APP_ID_HERE&redirect_uri=URI_HERE&scope=email

$graph_url = "https://graph.facebook.com/me?access_token=" 
. $params['access_token'];

$user = json_decode(file_get_contents($graph_url));
var_dump($user);

I am getting all the information that I need but I am not getting profile picture. I think this is because my profile picture is private. How do I get the profile picture even if its private. Do I have to add more permission scope?

Upvotes: 0

Views: 396

Answers (1)

The1Fitz
The1Fitz

Reputation: 672

The user photo is never returned when just making a request to the /me endpoint. In order to get the Users profile photo you have two options.

1) Using the 'fields' parameter you can request the users picture. e.g your request will become:

https://graph.facebook.com/me?fields=picture&access_token=<ACCESS_TOKEN>

2) You can also use the 'picture' edge on the user node which is described more here. This will make your request look like:

https://graph.facebook.com/me/picture?access_token=<ACCESS_TOKEN>

Once you have an access token for a user then there is no extra scope needed in order to get the profile picture.

Upvotes: 1

Related Questions