diff --git a/lib/Facebook.js b/lib/Facebook.js index 28db07c71..e8dad00eb 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -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 || {}); @@ -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) { @@ -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) { @@ -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'); @@ -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) { @@ -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) {