簡體   English   中英

如何通過PHP表單發送短信?

[英]How to send a SMS through PHP form?

我有一個用於發送短信的簡單 PHP 表單,我正在嘗試向一個號碼發送短信,但它給了我一條成功消息“短信已發送...”以及錯誤“用戶名/密碼無效”。

我通過將其放入瀏覽器來手動檢查鏈接它工作正常,我通過這個過程收到了短信......

請幫我解決這個問題!!!

<?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
));

並且絕對不會按如下方式傳遞您的網址:

curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
$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.....");

您可以使用 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM