Advertisement
a-mishra

Untitled

Apr 2nd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. <?php
  2.  
  3. $to = $_GET['to'];
  4. $msg = $_GET['sms'];
  5. echo "message is ". rawurlencode($msg);
  6. //echo "message is".$msg;
  7. //$to = "639189906040";
  8.  
  9. $str = $msg;
  10.  
  11. function utf8_to_unicode($str) {
  12.  
  13.     $unicode = array();
  14.     $values = array();
  15.     $lookingFor = 1;
  16.  
  17.     for ($i = 0; $i < strlen($str); $i++) {
  18.  
  19.         $thisValue = ord($str[$i]);
  20.  
  21.         if ($thisValue < 128)
  22.             $unicode[] = str_pad(dechex($thisValue), 4, "0", STR_PAD_LEFT);
  23.         else {
  24.             if (count($values) == 0) $lookingFor = ($thisValue < 224) ? 2 : 3;
  25.             $values[] = $thisValue;
  26.             if (count($values) == $lookingFor) {
  27.                 $number = ($lookingFor == 3) ?
  28.                 (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64):
  29.                 (($values[0] % 32) * 64) + ($values[1] % 64);
  30.                 $number = strtoupper(dechex($number));
  31.                 $unicode[] = str_pad($number, 4, "0", STR_PAD_LEFT);
  32.                 $values = array();
  33.                 $lookingFor = 1;
  34.             } // if
  35.         } // if
  36.     } // for
  37.     return ($unicode);
  38.  
  39. } // utf8_to_unicode
  40.  
  41. $hexArray = utf8_to_unicode($str);
  42.  
  43. $output = implode("", $hexArray);
  44.  
  45.     $user = "highway54";
  46.     $password = "RnaQi3LDur";
  47.     $api_id = "3445509";
  48.     $baseurl ="http://api.netvoice.com.ph/ameyosms/sendsms.php";
  49.     $unicode = "1NetVoice";
  50.  
  51. //$text = urlencode("This is Test");
  52. //$text = "$sms";
  53. //$to = "$phone";
  54. //auth call
  55. //$url = "$baseurl/bulksms/bulksms?username=$user&password=$password&type=6&dlr=0&destination=$to&source=novatelsms&message=$message";
  56.  
  57.      $url = "$baseurl?user=$user&password=$password&api_id=$api_id&to=$to&text=$output&unicode=$unicode";
  58.  
  59. echo $url;
  60.  
  61.    // do auth call
  62.    $ret = file($url);
  63.  
  64.    // explode our response. return string is on first line of the data returned
  65.    $sess = explode(":",$ret[0]);
  66.    if ($sess[0] == "OK") {
  67.        $sess_id = trim($sess[1]); // remove any whitespace
  68.        //$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
  69.  
  70.        // do sendmsg call
  71.        $ret = file($url);
  72.        $send = explode(":",$ret[0]);
  73.  
  74.         if ($send[0] == "ID") {
  75.             echo "successnmessage ID: ". $send[1];
  76.         } else {
  77.             echo "send message failed";
  78.         }
  79.     } else {
  80.         echo "NetVoice Response: ". $ret[0];
  81.     }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement