I'm a bit new to using the Facebook API and I'm currently trying to query the API for the user's profile picture. I am using this access-token return to get the user information when he/she logs in:
//Next get the user id of the current user, which is unique and will be used in the database
$response = file_get_contents("https://graph.facebook.com/me?fields=id,name,picture&access_token=$accessToken");
$data = json_decode($response);
print_r($data);
This print_r
outputs:
stdClass Object ( [
id] => 0000000000000000
[name] => Username
[picture] => stdClass Object (
[data] => stdClass Object (
[is_silhouette] => [url] => valid_url )
)
)
However, the picture is low-resolution and also 50x50. How can I get a higher quality image and a higher dimension? I couldn't find any information in the API.
I read the API (which added to my confusion), and it first asked me to add a
redirect=false
in my query (it was using an
HTTP GET
method)
I can specify it correctly in the http_get
method
Fetch image based on Facebook id of user and you can get every size of image like below example :
Large : https://graph.facebook.com/ {facebookId}/picture?type=large
You can change type based on your requirement here is the some type normal,small,square.
You can also use custom width and height for get any size profile picture by link http://graph.facebook.com/ {facebook-user-id}/picture?width=1000&height=1000
and for type parameter you can use {small, normal, album, large, square}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.