How can I get a high quality profile picture using React Native Facebook SDK GraphRequest?
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.
try {
const currentAccessToken = await AccessToken.getCurrentAccessToken()
const graphRequest = new GraphRequest('/me', {
accessToken: currentAccessToken.accessToken,
parameters: {
fields: {
string: 'picture.type(large)',
},
},
}, (error, result) => {
if (error) {
console.error(error)
} else {
console.log(result.picture.data.url)
}
})
new GraphRequestManager().addRequest(graphRequest).start()
} catch (error) {
console.error(error)
}