fbsamples / fbsamples/original-coast-clothing
Send fails for Apps without advance User Profile Access
- Dominant language
- JavaScript
- Stars
- 231
- Forks
- 239
- PR merge metrics
- No merged PRs in 30d
Description
Most new apps won't have access to user extra data, so the API call will fail to execute if the api call requests any of these advance unapproved fields.
https://developers.facebook.com/docs/messenger-platform/identity/user-profile/
## Suggestion
Let's include two new env variables that allow developers to setup if advance fields are available for the page and as well as setup their default preferred locale easily.
```
has_extra_user_field_accesss: process.env.HAS_EXTRA_USER_FIELD_ACCESSS || false,
default_locale: process.env.DEFAULT_LOCALE || 'en_US',
```
in https://github.com/fbsamples/original-coast-clothing/blob/master/services/config.js
Then use the above vars like:
```
let fields = 'first_name, last_name';
if (config.has_extra_user_field_accesss) {
fields = 'first_name, last_name, gender, timezone, locale';
}
```
in https://github.com/fbsamples/original-coast-clothing/blob/master/services/graph-api.js#L138
```
if (users[senderPsid].locale != null) {
i18n.setLocale(users[senderPsid].locale);
} else {
i18n.setLocale(config.default_locale);
}
```
https://github.com/fbsamples/original-coast-clothing/blob/master/app.js#L131
Contributor guide
Assessment
This issue has not been assessed yet.