使用php通过API集成发送SMS
下面的代码包含HTML和PHP代码。我将SMS API与HTML集成,但它不起作用。它不会向我显示任何错误消息。我需要你在这方面帮助我。我想通过这个API成功地发送短信。HTML部分包含短信发送字段的结构,PHP实际上包含API代码使用php通过API集成发送SMS,php,api,integration,Php,Api,Integration,下面的代码包含HTML和PHP代码。我将SMS API与HTML集成,但它不起作用。它不会向我显示任何错误消息。我需要你在这方面帮助我。我想通过这个API成功地发送短信。HTML部分包含短信发送字段的结构,PHP实际上包含API代码 <pre> <!DOCTYPE html> <html> <head> <title> Sending SMS using PHP
<pre>
<!DOCTYPE html>
<html>
<head>
<title>
Sending SMS using PHP
</title>
</head>
<body>
<form method="post">
<br><br>
<label>Mobile Number:</label>
<input type="text" name="num">
<br><br>
<label>Country Code:</label>
<select name="code">
<option value="">Select Here</option>
<option value="92">Pakistan - +92</option>
<option value="91">India - +91</option>
<option value="1">USA - +1</option>
</select>
<br><br>
<label>Enter Message</label>
<input type="text" name="message">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
if (isset($_POST["submit"])) {
// Authorisation details.
$username = "example@gmail.com";
$hash = "some_hash";
// Config variables. Consult http://api.txtlocal.com/docs for more info.
$test = "0";
// Data for text message. This is the text message data.
$sender = "API Test"; // This is who the message appears to be from.
$numbers = $_POST["code"] . $_POST["num"]; // A single number or a comma-seperated list of numbers
$message = $_POST["message"];
// 612 chars or less
// A single number or a comma-seperated list of numbers
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
$ch = curl_init('http://api.txtlocal.com/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the API
curl_close($ch);
if (!$result) {
?>
<script>
alert('Message Not Sent...!')
</script>
<?php}
else{
#print result
echo $result;
?>
<script>
alert('Message Sent Sucessfully...!')
</script>
<?php
}
}
?>
</pre>
使用PHP发送短信
手机号码:
国家代码:
选择这里
巴基斯坦-+92
印度-+91
美国-+1
输入消息
警报('消息未发送…!')
警报('消息已成功发送…!')
我非常建议您隐藏授权令牌并向我们提供错误。它没有显示任何错误..也没有生成错误alert@Baummit Augen已删除授权令牌。谢谢您…现在,请给我解决方案。