<?php
function curl_string ($url,$userAgent,$params){
       $ch = curl_init();
       curl_setopt ($ch, CURLOPT_POST,1);
       curl_setopt ($ch, CURLOPT_POSTFIELDS,$params);
       curl_setopt ($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_USERAGENT, $userAgent);
       curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
       curl_setopt ($ch, CURLOPT_HEADER, 0);
       curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
       $result = curl_exec ($ch);
       curl_close($ch);
       return $result;
}

$userAgent = "Mozilla/4.0";
$url = "https://www.commzgate.net/gateway/SendMsg";

$id="your_api_id";  //Get this under the Web API section
$password="your_api_password";  //You need to set this under Account Profile
$type="U";		//U for Unicode message content
$mobile="6590000000";  //Change this to a valid mobile number, alwasy include country code
$message="新年新气象";

$k=mb_convert_encoding($message, "UTF-16","UTF-8");
							
$k_hex=unpack("H*", $k);
$messageHex=implode(",", $k_hex);

$params ="ID=$id&Password=$password&Mobile=$mobile&Type=$type&Message=$messageHex"; 

$result = curl_string ($url,$userAgent,$params);
echo $result."<br />";

?>
