bootbot
bootbot copied to clipboard
getUserProfile() default fields
Hello! ✌️
Permissions my application ("locale", "timezone", "gender" unavailable):

Next, we downloaded current version package (1.0.16), used method "getUserProfile()" and get the follow error 😑:
{
"error":{
"message":"(#100) Insufficient permission to access user profile.",
"type":"OAuthException",
"code":100,
"error_subcode":2018247,
"fbtrace_id":"CZW1EcCa704"
}
}
Changed method "getUserProfile()":
getUserProfile(userId, fields) {
const defaultFields = ['id', 'name', 'first_name', 'last_name', 'profile_pic'];
if (!Array.isArray(fields)) {
throw new Error('Fields is supposed to be an array');
} else Array.prototype.push.apply(defaultFields, fields.map(field => field.trim()));
const mergeFields = defaultFields.join(',');
const url = `https://graph.facebook.com/${this.graphApiVersion}/${userId}?fields=${mergeFields}&access_token=${this.accessToken}`;
return fetch(url)
.then(res => res.json())
.catch(err => console.log(`Error getting user profile: ${err}`));
}
Thanks!
@Charca
What do you say? 🙄
Hi, I think this PR is important and resolve a lot issues #150 with recent policy changes of Facebook. I wonder if @drezo could update the PR? Thanks.