如何通过 PHP 表单发送短信?
How to send a SMS through PHP form?
我有一个用于发送短信的简单 PHP 表单,我正在尝试向一个号码发送短信,但它给了我一条成功消息 "SMS has sent..." 以及错误消息 "Invalid Username/Password".
我通过将其放入浏览器手动检查 link 它工作正常,我通过这个过程收到了短信....
请帮我解决这个问题!!!
<?php
if(isset($_POST['submit']))
{
$number=$_POST['numbertext'].$_POST['number'];
$message=$_POST['message'];
$var="http://sms.************.com/*****.asp?user=username&password=
password&sender=sender&sendercdma=**********&text=".$message."&PhoneNumber=".$number."&track=1";
echo $var;
$curl=curl_init('http://sms.************.com/*****.asp');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec($curl);
echo $result;
curl_close($curl);
die("SMS has sent.....");
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post">
Number:<br/>
<input type="text" name="numbertext" />-<input type="text" name="number" />
<br/><br/>
<br/><br/>
Message:<br/>
<textarea name="message"></textarea>
<input type="submit" name="submit" value="Send"/>
</form>
</body>
</html>
通过 msg91 API 发送了短信,我仍然不清楚你的 API 输入。
$YourAuthKey="Your Key";
$mobiles="number";
$message="Transactional Message";
$country=91;
$senderid="XYZMSG";
$url="https://control.msg91.com/api/sendhttp.php?authkey=".$YourAuthKey."&mobiles=".$mobiles."&message=".$message."&sender=".$senderid."&route=4&country=91";
echo $url;
header("Location: $url");
通过检查他们的api,你应该做如下:
$postData = array(
'authkey' => $authKey,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);
//API URL
$url="https://control.msg91.com/api/sendhttp.php";
// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
));
并且绝对不会通过您的 url 如下:
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
您可以使用 mvayoo api 轻松发送短信
首先在 www.mvaayoo.com 上创建帐户。然后你会得到你的用户名,密码详细信息。在下面的代码中填写此详细信息并轻松发送短信
<?php$ch = curl_init();
$user="enter your account email id here:enter your password here";
$receipientno="enter recivermobile number here";
$senderID="TEST SMS";
$msgtxt="this is test message, test";
curl_setopt($ch,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"user=$user&senderID=$senderID&receipientno=$receipientno&msgtxt=$msgtxt");
$buffer = curl_exec($ch);
if(empty ($buffer)){
echo " buffer is empty ";
}else{
echo $buffer;
}
curl_close($ch);
>
www.gajabwap.blogspot.in
$YourAuthKey="authkey";
$mobiles="mobile";
$message="demo";
$country=91;
$senderid="625552";// your sender id should be 6 digit
$url="http://********/api/*****.php?authkey=$YourAuthKey&mobiles=$mobiles&message=$message&sender=$senderid&route=4&country=$country";
//回显$url;
$curl=curl_init('http://*******/api/*****.php');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec($curl);
echo $result;
curl_close($curl);
die("SMS has sent.....");
我有一个用于发送短信的简单 PHP 表单,我正在尝试向一个号码发送短信,但它给了我一条成功消息 "SMS has sent..." 以及错误消息 "Invalid Username/Password".
我通过将其放入浏览器手动检查 link 它工作正常,我通过这个过程收到了短信....
请帮我解决这个问题!!!
<?php
if(isset($_POST['submit']))
{
$number=$_POST['numbertext'].$_POST['number'];
$message=$_POST['message'];
$var="http://sms.************.com/*****.asp?user=username&password=
password&sender=sender&sendercdma=**********&text=".$message."&PhoneNumber=".$number."&track=1";
echo $var;
$curl=curl_init('http://sms.************.com/*****.asp');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec($curl);
echo $result;
curl_close($curl);
die("SMS has sent.....");
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post">
Number:<br/>
<input type="text" name="numbertext" />-<input type="text" name="number" />
<br/><br/>
<br/><br/>
Message:<br/>
<textarea name="message"></textarea>
<input type="submit" name="submit" value="Send"/>
</form>
</body>
</html>
通过 msg91 API 发送了短信,我仍然不清楚你的 API 输入。
$YourAuthKey="Your Key";
$mobiles="number";
$message="Transactional Message";
$country=91;
$senderid="XYZMSG";
$url="https://control.msg91.com/api/sendhttp.php?authkey=".$YourAuthKey."&mobiles=".$mobiles."&message=".$message."&sender=".$senderid."&route=4&country=91";
echo $url;
header("Location: $url");
通过检查他们的api,你应该做如下:
$postData = array(
'authkey' => $authKey,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);
//API URL
$url="https://control.msg91.com/api/sendhttp.php";
// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
));
并且绝对不会通过您的 url 如下:
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
您可以使用 mvayoo api 轻松发送短信 首先在 www.mvaayoo.com 上创建帐户。然后你会得到你的用户名,密码详细信息。在下面的代码中填写此详细信息并轻松发送短信
<?php$ch = curl_init();
$user="enter your account email id here:enter your password here";
$receipientno="enter recivermobile number here";
$senderID="TEST SMS";
$msgtxt="this is test message, test";
curl_setopt($ch,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"user=$user&senderID=$senderID&receipientno=$receipientno&msgtxt=$msgtxt");
$buffer = curl_exec($ch);
if(empty ($buffer)){
echo " buffer is empty ";
}else{
echo $buffer;
}
curl_close($ch);
>
www.gajabwap.blogspot.in
$YourAuthKey="authkey";
$mobiles="mobile";
$message="demo";
$country=91;
$senderid="625552";// your sender id should be 6 digit
$url="http://********/api/*****.php?authkey=$YourAuthKey&mobiles=$mobiles&message=$message&sender=$senderid&route=4&country=$country";
//回显$url;
$curl=curl_init('http://*******/api/*****.php');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec($curl);
echo $result;
curl_close($curl);
die("SMS has sent.....");