Skip to content

Instantly share code, notes, and snippets.

View IbrahimTareq's full-sized avatar
🎯
Focusing

Ibrahim IbrahimTareq

🎯
Focusing
View GitHub Profile
@IbrahimTareq
IbrahimTareq / integrateFbPage.js
Last active June 17, 2018 23:19
Code snippet on how to integrate a Facebook page using the MessageMedia Conversations Node.js SDK.
const lib = require('messagemedia-conversations-sdk');
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "API_SECRET"; // The password to use with basic authentication
var controller = lib.FacebookController;
var facebookPageId = 'facebookPageId';
@IbrahimTareq
IbrahimTareq / getFbPages.js
Last active June 17, 2018 23:20
Code snippet on how to retrieve Facebook pages that exist for an account using the MessageMedia Conversations Node.js SDK.
const lib = require('messagemedia-conversations-sdk');
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "API_SECRET"; // The password to use with basic authentication
var controller = lib.FacebookController;
controller.getFacebookPages(function(error, response, context) {
console.log(response);
@IbrahimTareq
IbrahimTareq / authorizeFb.js
Last active June 17, 2018 23:20
Code snippet on how to perform Facebook authorization using the MessageMedia Conversations Node.js SDK.
const lib = require('messagemedia-conversations-sdk');
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "API_SECRET"; // The password to use with basic authentication
var controller = lib.FacebookController;
controller.getFacebookAuthorisationURL(function(error, response, context) {
console.log(response);
@IbrahimTareq
IbrahimTareq / provision.js
Last active June 17, 2018 23:21
Code snippet on how to provision an account using the MessageMedia Conversations Node.js SDK.
const lib = require('messagemedia-conversations-sdk');
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "API_SECRET"; // The password to use with basic authentication
var controller = lib.ConfigurationController;
var request = new lib.ConfigureAccountRequest({
"name": "Rainbow Serpent Festival",
@IbrahimTareq
IbrahimTareq / create-webhook-xml.js
Last active May 24, 2018 02:19
Code snippet on how to create a webhook using the MessageMedia Webhooks Node.js SDK.
function createWebhook(){
var controller = setup();
// Create body of your webhook
var body = new lib.CreateWebhookRequest({
"url": "http://webhook.com", // URL of the webhook
"method": "POST", // HTTP method
"encoding": "JSON", // Content type of the request
"events": [
"RECEIVED_SMS" // Webhook subscribed to RECEIVED_SMS event which is triggered when an SMS is received
@IbrahimTareq
IbrahimTareq / setup-webhooks.js
Created May 21, 2018 05:00
Code snippet on how to include the SDK and some general authentication and controller setup using the MessageMedia Webhooks Node.js SDK.
const lib = require('messagemedia-webhooks-sdk');
// Sets your auth credentials and creates controller which is used to call the createWebhook function from the SDK
function setup(){
var controller;
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY";
lib.Configuration.basicAuthPassword = "API_SECRET";
controller = lib.WebhooksController;
@IbrahimTareq
IbrahimTareq / delete-webhook.js
Last active May 21, 2018 04:58
Code snippet on how to delete a webhook using the MessageMedia Webhooks Node.js SDK.
function deleteWebhook(){
var controller = setup();
// The id of the webhook that you would like to delete
var webhookId = "WEBHOOK_ID";
// Call the function that deletes the webhook
controller.deleteWebhook(webhookId, function(error, response, context) {
console.log(response);
});
@IbrahimTareq
IbrahimTareq / update-webhook.js
Last active May 24, 2018 02:50
Code snippet on how to update a webhook using the MessageMedia Webhooks Node.js SDK.
function updateWebhook(){
var webhookId = "WEBHOOK_ID";
var body = new lib.UpdateWebhookRequest({
"url": "https://myurl.com",
"method": "GET",
"encoding": "FORM_ENCODED",
"events": [
"RECEIVED_SMS"
],
@IbrahimTareq
IbrahimTareq / retrieve-webhooks.js
Created May 21, 2018 04:42
Code snippet on how to retrieve all webhooks created using the MessageMedia Webhooks Node.js SDK.
function retrieveWebhook(){
var controller = setup();
var page = 0;
var pageSize = 0;
controller.retrieveWebhook(page, pageSize, function(error, response, context) {
console.log(response);
});
}
@IbrahimTareq
IbrahimTareq / create-webhook.js
Last active May 24, 2018 02:39
Code snippet on how to create a webhook using the MessageMedia Webhooks Node.js SDK.
const lib = require('messagemedia-webhooks-sdk');
// Sets your auth credentials and creates controller which is used to call the createWebhook function from the SDK
function setup(){
var controller;
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "API_KEY";
lib.Configuration.basicAuthPassword = "API_SECRET";
controller = lib.WebhooksController;