Skip to content

Instantly share code, notes, and snippets.

View derduskenga's full-sized avatar

Derdus derduskenga

View GitHub Profile
include_once 'util.php';
include_once 'db.php';
include_once 'user.php';
include_once 'sms.php';
class Survey {
protected $title;
protected $description;
public function addUserToSurvey ($pdo, $users, $surveyId, $level,$invitationsStatus){
//$users is an indexed array of phone numbers.
include_once 'util.php';
include_once 'db.php';
class User {
protected $phoneNumber;
protected $name;
public function allPhoneNumbers($pdo){
//returns an array of phone numbers
$stmt = $pdo->prepare("SELECT phone_number FROM user");
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- Host:
-- Generation Time: Jul 28, 2021 at 02:05 PM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.7
public function registerMenu($textArray, $phoneNumber){
//building menu for user registration
$level = count($textArray);
if($level == 1){
echo "CON Please enter your full name:";
} else if($level == 2){
echo "CON Please enter set you PIN:";
}else if($level == 3){
echo "CON Please re-enter your PIN:";
}else if($level == 4){
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;
include_once 'util.php';
class Sms {
protected $AT;
function __construct()
$this->AT = new AfricasTalking(Util::$API_USERNAME, Util::$API_KEY);
public function goToMainMenu($text){
$explodedText = explode("*",$text);
while(array_search(Util::$GO_TO_MAIN_MENU, $explodedText) != false){
$firstIndex = array_search(Util::$GO_TO_MAIN_MENU, $explodedText);
$explodedText = array_slice($explodedText, $firstIndex + 1);
return join("*",$explodedText);
derduskenga / index.php
Last active July 27, 2021 10:54
Implementing a mobile money USSD menu with branded SMS app
$menu = new Menu();
if($text == "" && $isUserRegistered == true){
//user is registered and string is is empty
echo "CON " . $menu->mainMenuRegistered("<Add a name here>");
}else if($text == "" && $isUserRegistered== false){
//user is unregistered and string is is empty
}else if($isUserRegistered== false){
//user is unregistered and string is not empty
derduskenga / home.js
Created September 23, 2020 16:42
This is a gist example
console.log('Testing something')
const express = require('express');
const routes = require('./routes/userRoutes');
const Parser = require('body-parser');
const app = express();
const express = require('express');
const userController = require('../controllers/userController');
const route = express.Router();'/user', userController.newUser);
module.exports = route;