<?php

require_once dirname(__FILE__) . "/bulksms/BulkSMS.php";
$bulksms = new BulkSMS();
$USERNAME = "******";
$PASSWORD = "******";
// Login
$bulksms->login($USERNAME, $PASSWORD);
# Print all routes
$routes = $bulksms->getRoutePricing();
foreach ($routes as $route) {
    echo $route->getCountryName() . "\t" . $route->getUserRouteId() . "\t" . $route->getPrice() . "\n";
}
# Get route/pricing for specific country
$routePricing = $bulksms->getRoutePricingByCountry("Australia");
if ($routePricing != null) {
    echo "Country:\t" . $routePricing->getCountryName() . "\n";
    echo "Description: \t" . $routePricing->getDescription() . "\n";
    echo "Route Id:\t" . $routePricing->getUserRouteId() . "\n";
    echo "Price:   \t" . $routePricing->getPrice() . "\n";
}
# Get route id for specific country
$country = "United Kingdom";
$routeId = $bulksms->getRouteIdByCountry($country);
echo "Route ID for {$country}: {$routeId}\n";
Beispiel #2
0
<?php

require_once "BulkSMS.php";
$obj = new BulkSMS('E7GEZLY', 'BSMS', 'http://smsbulk.eg.mobizone.mobi/BSMS/BSendAPI?');
//message body , language , recipient , sender
$obj->sendSMS('لقد تم الجز', 'ar', 201281264677.0, 'E7gezly');
Beispiel #3
-1
 protected function sendMessage($sender, $message, $recepients, $loginId = '')
 {
     if (!class_exists('Message')) {
         $this->loadModel('Message');
     }
     if (!class_exists('BulkSMS')) {
         $this->loadModel('BulkSMS');
     }
     if (empty($loginId)) {
         $loginId = $_SESSION['loginId'];
     }
     $user = new User($loginId);
     $len = strlen($message);
     $msgNo = $len < 160 ? 1 : ($len - $len % 160) / 160;
     $msgNo = $len > 160 && $len % 160 != 0 ? $msgNo + 1 : $msgNo;
     $count = ceil(count(explode(',', $recepients)) * $msgNo);
     $avu = $user->Balance * 1;
     $uneeded = $count * UNITS_PER_SMS;
     if ($user->Balance < $uneeded) {
         return 'Insufficient balance';
     }
     $recepients = str_replace(',0', ',234', $recepients);
     $url = API_URL . 'api/sendMessage?returnDetails=1&loginId=' . API_USERNAME . '&password='******'&sender=' . urlencode($sender) . '&message=' . urlencode($message) . '&recipients=' . urlencode(trim($recepients));
     $xml = file_get_contents($url);
     //check if message sent and deduct
     if (strpos($xml, '1701') !== FALSE) {
         $user->Balance -= $count * UNITS_PER_SMS;
         $user->Save();
         $notification = "Messae sent";
         $bulksSMS = new BulkSMS();
         $bulksSMS->LoginId = $user->LoginId;
         $bulksSMS->Message = $message;
         $bulksSMS->Sender = $sender;
         $bulksSMS->Status = '1701';
         $bulksSMS->Count = $count;
         $bulksSMS->Save();
         $messages = array();
         $nos = explode(',', $recepients);
         foreach ($nos as $no) {
             if (empty($no)) {
                 continue;
             }
             $sms = new Message();
             $sms->BulkSMSId = $bulksSMS->Id;
             $sms->Number = $no;
             $sms->Message = $message;
             $sms->Sender = $sender;
             $sms->RefId = -1;
             $sms->Status = '1701';
             $messages[] = $sms;
         }
         $bulksSMS->SaveMessages($messages);
     }
     return $xml;
 }