bootbot icon indicating copy to clipboard operation
bootbot copied to clipboard

getUserProfile() default fields

Open drezo opened this issue 6 years ago • 2 comments

Hello! ✌️

Permissions my application ("locale", "timezone", "gender" unavailable):

2019-01-17 11 21 21

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!

drezo avatar Jan 17 '19 08:01 drezo

@Charca

What do you say? 🙄

drezo avatar Aug 04 '19 00:08 drezo

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.

lehainam-dev avatar Oct 25 '19 02:10 lehainam-dev