我正在将这个SMS API整合到Travel Genie中,http://www.travelgenieapp.com这是一个旅行软件。当用户到达该位置时,我们会发送短信。
http://sms.cannyinfotech.com/sendsms.jsp?user=(xxxxxx)&password=(xxxxxxx) &mobiles=9659051538&sms=MESSAGE&unicode=0&senderid=CMREDU &version=3
我正在使用以下PHP代码:
<?php
//Code using curl
//Change your configurations here.
//---------------------------------
$username = "amitpro";
$api_password = "demo1234";
$sender = "sender";
$domain = "sms.cannyinfotech.com";
$priority = "1"; // 1-Normal,2-Priority,3-Marketing
$method = "POST";
//---------------------------------
if (isset($_REQUEST['send'])) {
$mobile = $_REQUEST['mobile'];
$message = $_REQUEST['message'];
$username = urlencode($username);
$password = urlencode($password);
$sender = urlencode($sender);
$message = urlencode($message);
$parameters = "user=$username&password=$api_password&senderid=$sender&mobiles=$mobile&sms=$message&unicode=0&version=3";
$url = "http://$domain/sendsms.jsp?";
$ch = curl_init($url);
if ($method == "POST") {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
} else {
$get_url = $url . "?" . $parameters;
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, $get_url);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL
$return_val = curl_exec($ch);
if ($return_val == "")
echo "Process Failed, Please check domain, username and password.";
else
echo "$return_val";
}
echo "<form name='f1' method='post'>";
echo "<p> Mobile: <input name='mobile' > </p>";
echo "<p> Message: <textarea name='message' ></textarea> </p>";
echo "<p> <input type='submit' value='Send' name='send'></p>";
echo "</form";
?>
我在上面的PHP上遇到错误。 有人可以建议一个替代的PHP代码吗?
上述代码由Canny Infotech.
提供