I’m trying to get a high resolution picture using the React Native Facebook SDK, however the default image quality is very poor. It’s 50×50 and very low resolution.
Request:
new GraphRequest('/135121013672357',
{
parameters: {
fields: {
string: 'picture'
}
}
},
_responseInfoCallback
)
Response
{
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/16864988_145199975997794_4154735936748679550_n.jpg?oh=bb5f32ecb73dd9b8fb8ac45920e2ffc5&oe=593223A8"
}
},
"id": "135121013672357"
}
Looking at Facebook’s Graph API docs, there is a parameter, “type”, whereby one can request a particular size (small, medium, large). What isn’t clear however, is how to format that request.
picture?type=large // Error
picture{type:large} // 200 However, picture is omitted from Response
4
Answers
Try using Graph API field expansion to get the resource:
picture.type(large)
You can also use .height and .width to get an even higher resolution picture or a resolution you need it at:
Example endpoint for
480x{any-width}
image:/me?fields=id,name,picture.height(480),[:other_fields]
Example endpoint for
{any-height}x480
image:/me?fields=id,name,picture.width(480),[:other_fields]
Example endpoint for maximum resolution image:
/me?fields=id,name,picture.height(10000),[:others_fields]
Official documentation is at the
/{node-id}/picture
page at https://developers.facebook.com/docs/graph-api/reference/user/picture/.And you can try the API out without debugging through the app at: https://developers.facebook.com/tools/explorer/
Here is an example about how we can get a large Facebook user profile’s picture on a simple way using the react-native-fbsdk package.