<?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(); }
$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); try { // Quick Send approach SMSGH quick send $messageResponse = $messagingApi->sendQuickMessage("CodeWreaker", $student_phone, "{$student_name} This is your login password {$random_pass}"); if ($messageResponse instanceof MessageResponse) { echo "msg1: " . $messageResponse->getStatus() . "</br></br>"; } elseif ($messageResponse instanceof HDpResponse) { echo "\nServer Response Status : " . $messageResponse->getStatus() . "</br></br>"; } echo "</br>success done"; } catch (ExcepWon $ex) { echo $ex->getTraceAsString(); }
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(); } }
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(); } }
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) { } }