Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ibrahim IbrahimTareq

🎯
Focusing
View GitHub Profile
@IbrahimTareq
IbrahimTareq / integrateFbPage.js
Last active Jun 17, 2018
Code snippet on how to integrate a Facebook page using the MessageMedia Conversations Node.js SDK.
View integrateFbPage.js
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 Jun 17, 2018
Code snippet on how to retrieve Facebook pages that exist for an account using the MessageMedia Conversations Node.js SDK.
View getFbPages.js
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 Jun 17, 2018
Code snippet on how to perform Facebook authorization using the MessageMedia Conversations Node.js SDK.
View authorizeFb.js
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 Jun 17, 2018
Code snippet on how to provision an account using the MessageMedia Conversations Node.js SDK.
View provision.js
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
Code snippet on how to create a webhook using the MessageMedia Webhooks Node.js SDK.
View create-webhook-xml.js
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
Code snippet on how to include the SDK and some general authentication and controller setup using the MessageMedia Webhooks Node.js SDK.
View setup-webhooks.js
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
Code snippet on how to delete a webhook using the MessageMedia Webhooks Node.js SDK.
View delete-webhook.js
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
Code snippet on how to update a webhook using the MessageMedia Webhooks Node.js SDK.
View update-webhook.js
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
Code snippet on how to retrieve all webhooks created using the MessageMedia Webhooks Node.js SDK.
View retrieve-webhooks.js
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
Code snippet on how to create a webhook using the MessageMedia Webhooks Node.js SDK.
View create-webhook.js
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;
You can’t perform that action at this time.