Skip to content

Instantly share code, notes, and snippets.

@JaniKibichi
JaniKibichi / mongodb.service
Created February 20, 2017 07:19
Configuration file for the mongodb service on Ubuntu 16.04
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
@JaniKibichi
JaniKibichi / endpoints.c
Last active December 20, 2022 23:06
cURL Endpoints
Sandbox End Points
1. SMS
Make a HTTP POST request to https://api.sandbox.africastalking.com/version1/messaging
See the Parameters
curl -v -H "Accept: application/json" \
-d "username=sandBoxUserName&message=hello test&to=+254711XXXYYY,+254733YYYZZZ" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-X POST http://api.sandbox.africastalking.com/version1/messaging --insecure
@JaniKibichi
JaniKibichi / ussdSwitch.php
Created March 16, 2017 04:16
An example of a USSD switch statement
<?php
//1. Ensure ths code runs only after a POST from AT
if(!empty($_POST) && !empty($_POST['phoneNumber'])){
require_once('dbConnector.php');
require_once('AfricasTalkingGateway.php');
require_once('config.php');
//2. receive the POST from AT
$sessionId =$_POST['sessionId'];
$serviceCode =$_POST['serviceCode'];
@JaniKibichi
JaniKibichi / on-demand.php
Created March 21, 2017 08:38
SMS On-demand Script - AT
<?php
//Receive POST from AT
$Sender = $_POST['from'];
$to = $_POST['to'];
$text = $_POST['text'];
$date = $_POST['date'];
$id = $_POST['id'];
$linkId = $_POST['linkId']; //This works for onDemand subscription products
if(!empty($_POST['from'])){
@JaniKibichi
JaniKibichi / voiceCall.php
Created March 21, 2017 10:43
VoiceCall-IVR
<?php
// This is a unique ID generated for this call
$sessionId = $_POST['sessionId'];
$isActive = $_POST['isActive'];
if ($isActive == 1) {
$callerNumber = $_POST['callerNumber'];
// Compose the response
$response = '<?xml version="1.0" encoding="UTF-8"?>';
@JaniKibichi
JaniKibichi / voiceMenu.php
Created March 21, 2017 10:49
Voice Menus
<?php
//1. Receive POST from AT
$isActive = $_POST['isActive'];
$callerNumber =$_POST['callerNumber'];
$dtmfDigits = $_POST['dtmfDigits'];
$sessionId = $_POST['sessionId'];
//2. Check if isActive=1 to act on the call or isActive=='0' to store the result
if($isActive=='1'){
//2a. Switch through the DTMFDigits
@JaniKibichi
JaniKibichi / ussd.cs
Last active October 5, 2024 12:31
USSD on c#
/*
A few things to note about USSD:
USSD is session driven. Every request we send you will contain a sessionId, and this will be maintained until that session is completed
You will need to let the Mobile Service Provider know whether the session is complete or not. If the session is ongoing, please begin your response with CON. If this is the last response for that session, begin your response with END.
If we get a HTTP error response (Code 40X) from your script, or a malformed response (does not begin with CON or END, we will terminate the USSD session gracefully.
using visual studio 2013 or Greater
go to file > new > project
in the projects window choose web under C#
select ASP.NET Web Application and name your project as you like
@JaniKibichi
JaniKibichi / Dockerfile
Created May 16, 2017 07:52
Dockerfile for PlaySMS and AT Gateway
#Pull ubuntu docker image
FROM ubuntu:14.04
MAINTAINER [email protected]
#Run Update
RUN apt-get -y update && apt-get -y update
#Install LAMP
RUN apt-get -y install apache2
#Mariadb
RUN apt-get update \
&&apt-get -y remove --purge mysql* \
@JaniKibichi
JaniKibichi / 2wayshortcode.php
Last active January 27, 2022 10:46
Shortcode
<?php
//receive the POST from AT on your POST ROUTE
$from = $_POST['from'];
$to = $_POST['to'];
$text = $_POST['text'];
$date = $_POST['date'];
$id = $_POST['id'];
$linkId = $_POST['linkId'];
//Respond based on backend events
if(!empty($_POST['from'])){
@JaniKibichi
JaniKibichi / build.sbt
Created June 8, 2017 04:28
An example of a Scala SBT file
#!/bin/bash
#------------------------------------------------------------------------------
# Name: sbtmkdirs
# Version: 1.4
# Purpose: Create an SBT project directory structure with a few simple options.
# Author: Alvin Alexander, http://alvinalexander.com
# License: Creative Commons Attribution-ShareAlike 2.5 Generic
# http://creativecommons.org/licenses/by-sa/2.5/
#------------------------------------------------------------------------------