Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility of unlinking an account #91

Merged
merged 5 commits into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ Sends the sender action `senderAction` to the target `recipient`, and calls the
* `senderAction` - String: The sender action to execute. Can be one of: `typing_on`, 'typing_off', 'mark_seen'. See the [Sender Actions API reference](https://developers.facebook.com/docs/messenger-platform/send-api-reference/sender-actions) for more information.
* `callback` - (Optional) Function: Called with `(err, info)` once the request has completed. `err` contains an error, if any, and `info` contains the response from Facebook, usually with the new message's ID.

#### `bot.unlinkAccount(psid, [callback])`

Unlinks the user with the corresponding `psid`, and calls the callback if any. Returns a promise. See [Account Unlink Endpoint].(https://developers.facebook.com/docs/messenger-platform/identity/account-linking?locale=en_US#unlink)

* `psid` - Number: The Facebook ID of the user who has to be logged out.
* `callback` - (Optional) Function: Called with `(err, info)` once the request has completed. `err` contains an error, if any, and `info` contains the response from Facebook.

#### `bot.setGetStartedButton(payload, [callback])`
#### `bot.setPersistentMenu(payload, [callback])`

Expand Down
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ class Bot extends EventEmitter {
})
}

unlinkAccount (psid, cb) {
return request({
method: 'POST',
uri: 'https://graph.facebook.com/v2.6/me/unlink_accounts',
qs: this._getQs(),
json: {
psid: psid
}
})
.then(body => {
if (body.error) return Promise.reject(body.error)
if (!cb) return body
cb(null, body)
})
.catch(err => {
if (!cb) return Promise.reject(err)
cb(err)
})
}

getAttachmentUploadId (url, isReusable, type, cb) {
return request({
method: 'POST',
Expand Down