Exemple #1
0
<?php

// Let us test the SDK
require './Smsgh/Api.php';
$auth = new BasicAuth("user123", "password123");
// instance of ApiHost
$apiHost = new ApiHost($auth);
// instance of AccountApi
$accountApi = new AccountApi($apiHost);
// Get the account profile
// Let us try to send some message
$messagingApi = new MessagingApi($apiHost);
try {
    // Send a quick message
    $messageResponse = $messagingApi->sendQuickMessage("Husby", "+2332432191768", "I love you dearly Honey. See you in the evening...");
    $mesg = new Message();
    $mesg->setContent("I will eat the beautiful Food you have");
    $mesg->setTo("+233244219234");
    $mesg->setFrom("+233204567867");
    $mesg->setRegisteredDelivery(true);
    // Let us say we want to send the message 3 days from today
    $mesg->setTime(date('Y-m-d H:i:s', strtotime('+1 week')));
    $messageResponse = $messagingApi->sendMessage($mesg);
    if ($messageResponse instanceof MessageResponse) {
        echo $messageResponse->getStatus();
    } elseif ($messageResponse instanceof HttpResponse) {
        echo "\nServer Response Status : " . $messageResponse->getStatus();
    }
} catch (Exception $ex) {
    echo $ex->getTraceAsString();
}
<?php

include_once 'adb.php';
require '../Smsgh/Api.php';
// using clientId and clientSecret as credentials
$auth = new BasicAuth("yralkzfn", "znbzlsho");
// instance of ApiHost
$apiHost = new ApiHost($auth);
$messagingApi = new MessagingApi($apiHost);
$student_id = $_REQUEST['student_id'];
$student_name = $_REQUEST['student_name'];
$student_gpa = $_REQUEST['student_gpa'];
$student_major = $_REQUEST['student_major'];
$student_phone = $_REQUEST['student_phone'];
function generateRandomString($length = 10)
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMONPQRSTUVWXYZ';
    $charactersLength .= strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
$random_pass = generateRandomString(8);
echo "PASS: {$random_pass}";
/** PARTS OF THE MESSAGE ***/
$obj = new adb();
// check if ISSET
$str = "INSERT INTO `sms_messages` SET  `student_id`='{$student_id}',\n    `student_name`='{$student_name}', `student_gpa`='{$student_gpa}',\n    `student_major`='{$student_major}', `student_phone`='{$student_phone}'";
$result = $obj->query($str);
function sms($msg, $num)
{
    //Here we assume the user is using the combination of his clientId and clientSecret as credentials
    $auth = new BasicAuth("igkoydll", "dngiqlfo");
    // instance of ApiHost
    $apiHost = new ApiHost($auth);
    $enableConsoleLog = FALSE;
    $messagingApi = new MessagingApi($apiHost, $enableConsoleLog);
    try {
        $messageResponse = $messagingApi->sendQuickMessage("MyStore", $num, $msg);
        if ($messageResponse instanceof MessageResponse) {
            //echo
            $messageResponse->getStatus();
        } elseif ($messageResponse instanceof HttpResponse) {
            //echo "\nServer Response Status : " .
            $messageResponse->getStatus();
        }
    } catch (Exception $ex) {
        //echo
        $ex->getTraceAsString();
    }
}
Exemple #4
0
function sendPurchaseNotification($phone, $message)
{
    try {
        require_once 'Smsgh/Api.php';
        $auth = new BasicAuth("jokyhrvs", "volkzmqn");
        $apiHost = new ApiHost($auth);
        $messagingApi = new MessagingApi($apiHost);
        $messageResponse = $messagingApi->sendQuickMessage("Book Store", "+" . $phone, $message);
        if ($messageResponse instanceof MessageResponse) {
            //echo $messageResponse->getStatus();
            return true;
        } elseif ($messageResponse instanceof HttpResponse) {
            //echo "\nServer Response Status : " . $messageResponse->getStatus();
            return false;
        }
    } catch (Exception $ex) {
        echo $ex->getTraceAsString();
    }
}
Exemple #5
0
if (!isset($_GET['phone'])) {
    echo '{"result": 0, "message": "There was a problem try sending again"}';
    return;
}
$customer = $_GET['phone'];
$newMessage = "10% discount on your next purchase";
require 'Smsgh/Api.php';
//$auth = new BasicAuth("yralkzfn", "znbzlsho");
$auth = new BasicAuth("obxffxqt", "wmqimxzt");
// instance of ApiHost
$apiHost = new ApiHost($auth);
// instance of AccountApi
$accountApi = new AccountApi($apiHost);
// Get the account profile
// Let us try to send some message
$messagingApi = new MessagingApi($apiHost);
try {
    // Send a quick message
    //$messageResponse = $messagingApi->sendQuickMessage("Husby", "+2332432191768", "I love you dearly Honey. See you in the evening...");
    $mesg = new Message();
    $mesg->setContent($newMessage);
    $mesg->setTo($customer);
    $mesg->setFrom("+233543344100");
    $mesg->setRegisteredDelivery(true);
    // Let us say we want to send the message 3 days from today
    //$mesg->setTime(date('Y-m-d H:i:s', strtotime('+1 week')));
    $messageResponse = $messagingApi->sendMessage($mesg);
    if ($messageResponse instanceof MessageResponse) {
        echo '{"result": 1, "message": "' . $messageResponse->getStatus() . '"}';
        return;
        //echo $messageResponse->getStatus();
function send_smsgh($number, $message)
{
    require_once '../Smsgh/Api.php';
    //Authorization details
    $auth = new BasicAuth("yralkzfn", "znbzlsho");
    //instance of ApiHost
    $apiHost = new ApiHost($auth);
    $messagingApi = new MessagingApi($apiHost);
    try {
        $messageResponse = $messagingApi->sendQuickMessage("Important", $number, $message);
        if ($messageResponse instanceof MessageResponse) {
            echo "msg1:" . $messageResponse->getStatus() . "</br></br>";
        } else {
            if ($messageResponse instanceof HttpResponse) {
                echo "\nServer Response Status:" . $messageResponse->getStatus() . "</br></br>";
            }
        }
        echo "</br>success done";
    } catch (Exception $e) {
    }
}