有人可以帮助我通过HTTP发送短信PHP吗?我正在使用OneWaySMS菲律宾,它似乎不起作用。
以下是他们提供的API代码示例:
function gw_send_sms($user, $pass, $sms_from, $sms_to, $sms_msg)
{
$query_string = "api.aspx?apiusername=" . $user . "&apipassword=" . $pass;
$query_string .= "&senderid=" . rawurlencode($sms_from) . "&mobileno=" . rawurlencode($sms_to);
$query_string .= "&message=" . rawurlencode(stripslashes($sms_msg)) . "&languagetype=1";
$url = "http://gateway.onewaysms.com.au:10001/" . $query_string;
$fd = @implode('', file($url));
if ($fd) {
if ($fd > 0) {
Print("MT ID : " . $fd);
$ok = "success";
} else {
print("Please refer to API on Error : " . $fd);
$ok = "fail";
}
} else {
// no contact with gateway
$ok = "fail";
}
return $ok;
}
Print("Sending to one way sms " . gw_send_sms("apiusername", "apipassword", "senderid", "61412345678", "test message"));
这是我的代码(由于简单的代码没有用,我真的改变了它):
function gw_send_sms($user, $pass, $sms_from, $sms_to, $sms_msg)
{
$query_string = "api.aspx?apiusername=" . $user . "&apipassword=" . $pass;
$query_string .= "&senderid=" . rawurlencode($sms_from) . "&mobileno=" . rawurlencode($sms_to);
$query_string .= "&message=" . rawurlencode(stripslashes($sms_msg)) . "&languagetype=1";
$url = "http://gateway.onewaysms.com.ph:10001/" . $query_string;
$arr = array($url);
$fd = implode(',', $arr);
if ($fd) {
if ($fd > 0) {
Print("MT ID : " . $fd);
$ok = "success";
} else {
print("Please refer to API on Error : " . $fd);
$ok = "fail";
}
} else {
// no contact with gateway
$ok = "fail";
}
return $ok;
}
Print("Sending to one way sms " . gw_send_sms("sampleusername", "samplepassword", "Sender", "SampleNumber", "Testing SMS"));
请在错误时参考API: http://gateway.onewaysms.com.ph:10001/api.aspx?apiusername=sample&apipassword=sample&senderid=sample&mobileno=sample&message=Testing%20omg&languagetype=1 发送到单向短信失败
我也尝试过直接访问网址,但没有运气。
答案 0 :(得分:0)
您使用的是错误的域名,应该是gateway.onewaysms.ph而不是gateway.onewaysms.com.ph。