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 ability to customize api url for Facebook #567

Merged
merged 1 commit into from Mar 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var crypto = require('crypto');

function Facebookbot(configuration) {

var api_host = configuration.api_host || 'graph.facebook.com';

// Create a core botkit bot
var facebook_botkit = Botkit(configuration || {});

Expand Down Expand Up @@ -35,9 +37,6 @@ function Facebookbot(configuration) {

}




// customize the bot definition, which will be used when new connections
// spawn!
facebook_botkit.defineBot(function(botkit, config) {
Expand Down Expand Up @@ -127,7 +126,7 @@ function Facebookbot(configuration) {
'content-type': 'application/json',
},
body: facebook_message,
uri: 'https://graph.facebook.com/v2.6/me/messages'
uri: 'https://' + api_host + '/v2.6/me/messages'
},
function(err, res, body) {

Expand Down Expand Up @@ -382,7 +381,7 @@ function Facebookbot(configuration) {
});


request.post('https://graph.facebook.com/me/subscribed_apps?access_token=' + configuration.access_token,
request.post('https://' + api_host + '/me/subscribed_apps?access_token=' + configuration.access_token,
function(err, res, body) {
if (err) {
facebook_botkit.log('Could not subscribe to page messages');
Expand Down Expand Up @@ -449,7 +448,7 @@ function Facebookbot(configuration) {
facebook_botkit.api.thread_settings.deleteAPI(message);
},
postAPI: function(message) {
request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token,
request.post('https://' + api_host + '/v2.6/me/thread_settings?access_token=' + configuration.access_token,
{form: message},
function(err, res, body) {
if (err) {
Expand All @@ -475,7 +474,7 @@ function Facebookbot(configuration) {
});
},
deleteAPI: function(message) {
request.delete('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token,
request.delete('https://' + api_host + '/v2.6/me/thread_settings?access_token=' + configuration.access_token,
{form: message},
function(err, res, body) {
if (err) {
Expand Down