Reputation: 2371
I have a snippet of code in my Ionic 2 app that is supposed to grab the Facebook profile of the user after they have successfully logged on. I've verified that the request path /me
returns data associated with the user, however when I set the request path to /me/picture
, I get an error: There was an error making the graph call.
Here is my code:
if(this.platform.is('cordova')) {
Facebook.login([
'public_profile',
'user_friends',
'email'
]).then((result) => {
Facebook.api('/me?fields=id,name,email,cover', []).then(data => {
// Create the user object
let user = {
access_token: result.authResponse.accessToken,
display_name: data.name,
email: data.email,
facebook_id: data.id,
cover_photo: data.cover.source,
}
Facebook.api(`me/picture`, []).then(data => {
user['profile_photo'] = data.url;
this.loginWithFacebook(user);
}, error => { this.user = JSON.stringify(error)});
})
},
error => {
this.user = JSON.stringify(error);
})
}
Am I missing something? I've even tried doing /{user-id}/picture
and still receive an error. Anyone run into this issue?
Upvotes: 0
Views: 457
Reputation: 74004
By default this edge will return a 302 redirect to the picture image. To get access to the data about the picture, please include redirect=false in your query.
Source: https://developers.facebook.com/docs/graph-api/reference/user/picture/
For example: Facebook.api('me/picture?redirect=false', [])...
Upvotes: 3