Skip to content

Commit

Permalink
Merge pull request #567 from katsgeorgeek/custom_url
Browse files Browse the repository at this point in the history
Add ability to customize api url for Facebook
  • Loading branch information
Ben Brown committed Mar 9, 2017
2 parents 0ff7df0 + 5ae9de3 commit a5055f1
Showing 1 changed file with 6 additions and 7 deletions.
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 @@ -137,7 +136,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 @@ -409,7 +408,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 @@ -490,7 +489,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 @@ -516,7 +515,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

0 comments on commit a5055f1

Please sign in to comment.