GithubHelp home page GithubHelp logo

aft's Introduction

SMS Comms Module

This module integrates to the Africa Is Talking (AFT) API to send messages.

File Structure

aft
├── logs // Log Files for debug
|	├── sent_sms_logs.txt
| 	├── callback_logs.txt 
|	└── database_logs.txt
|
├── vendor // Vendor Files
├── callback.php // AFT callback handler
├── sms.php // Main file with send SMS
├── logger.php // Logger class
└── README.md

Using This Module

  • The sms.php file contains the callSmsApi function that accepts ($phone, $message, $orderId)
  • The callSmsApi function returns a JSON payload with the result of the operation
  • The function creates logs of sent SMSs to sent_sms_logs.txt
  • The getStatus function returns message details from the db.

Getting message status

  • Pass in either one of the following params:
     	$params = Array(
     		"orderId" => "orderxyz",
     		"sessionId" => "wxyz"
     	)
    
  • The function will query the database using the provided param and return a JSON payload of the message details.

AFT Callback

  • For a case where the SMS is not recieved immediately by the recipient e.g if the recipient's phone is on Airplane mode, the message status is marked as SENT.
  • As soon as AFT servers get an update from the Telco on the SMS deliver, they make a call to callback.php which picks the reponse and updates the status of the sent message i.e whether it was SUCCESSFUL or FAILED.
  • The module creates logs of callback actions to callback_logs.txt
  • More logic can be inserted into the module as necessary e.g to display response to a user

Logger

  • The logger module create log files as required
  • Simply instantiate $log = new Logger("sent_sms_logs.txt");
  • Insert desired log $log->insert(json_encode('This is a log'));

Database

  • The logger module uses SQLite to write SMS responses from AFT

Setting Up

  1. Create a new bitnami app follow the official docs:

    https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/
    
  2. Host the files there. In our case the app is called sms

    You can use git to pull code from your repository into the server.
    
  3. On the AFT console, navigate to the appropriate app

  4. Go to SMS > SMS Callback URLs > Delivery Reports

  5. Set the callback url as https://gobeba.com/sms/callback.php

Notes:

Ensure the owner of the **htdocs** folder of your app is set as **daemon**. This is because the system
will need to be able to create app resources like the sqlite db and log files in order to function.

Use the unix command:

sudo chown daemon:daemon -R htdocs

aft's People

Contributors

jaydroidbot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.