下面是我的代码。它应该在您在http://www.localsadvise.com/services-view/dolphin-cruises/上的字段表单中输入您的电话号码后发送一条 SMS 消息它不发送消息。
URL 必须是http://api.clickatell.com/http/sendmsg?后跟代码中下面列出的变量。我正在尝试使用 Php 脚本发送短信,而不必将浏览器定向到 clickatell 网站进行 HTTP 访问。如果那有意义的话。
// The original link that worked using a simple META Refresh after form submit
// http://api.clickatell.com/http/sendmsg?user=amdoch&password=OVUbMIXCZUeMIg&api_id=3536796&MO=1&from=19044383575&to=1". $phone . "&text=Dolphin%20Cruise%20Test%20Text
$user = "amdoch";
$password = "MYPASSWORDHERE";
$api_id = "MYAPIID";
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$phone = $_POST['phone'];
$from = "19044383575";
$to = $phone;
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
// do auth call
$ret = file($url);
// explode our response. return string is on first line of the data returned
$sess = explode(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?session_id=$sess_id&MO=1&from=$from&to=$to&text=$text";
// do sendmsg call
$ret = file($url);
$send = explode(":",$ret[0]);
if ($send[0] == "ID") {
echo "successnmessage ID: ". $send[1];
} else {
echo "<META http-equiv=refresh content=0;URL=http://www.localsadvise.com>send message failed";
}
} else {
echo "Authentication failure: ". $ret[0];
}