简体   繁体   English

如何从用 PHP 编写的 Web 服务器发送短信? 使用 Betamax 网址

[英]How to send an SMS from a web server written in PHP? using Betamax url

Betamax offers link to send sms , how to convert this links to php plus html form to send sms. Betamax 提供发送短信的链接,如何将此链接转换为 php 加 html 形式发送短信。

Using HTML SMSlink You can also send text messages (SMS) without using our software or accessing the website.使用 HTML SMSlink 您还可以在不使用我们的软件或访问网站的情况下发送文本消息 (SMS)。 Use the following link and fill in the desired data:使用以下链接并填写所需数据:

https://www.poivy.com/myaccount/sendsms.php?username=xxxxxxxxxx&password=xxxxxxxxxx&from=xxxxxxxxxx&to=xxxxxxxxxx&text=xxxxxxxxxx https://www.poivy.com/myaccount/sendsms.php?username=xxxxxxxxxx&password=xxxxxxxxxx&from=xxxxxxxxxx&to=xxxxxxxxxx&text=xxxxxxxxxxx

Explanation of the variables:变量说明:

username: your poivY username password: your poivY password from: your username or your verified phone number.用户名:您的 poivY 用户名密码:您的 poivY 密码来自:您的用户名或经过验证的电话号码。 Always use international format for the number starting with +, for instance +491701234567 to: the number you wish to send the sms to.对于以 + 开头的号码,请始终使用国际格式,例如 +491701234567 to: 您希望向其发送短信的号码。 Always use international format starting with +, for instance +491701234567 text: the message you want to send始终使用以 + 开头的国际格式,例如 +491701234567 text: 您要发送的消息

If you know the service provider, just use the phone number and the service provider email, it's a back-end way to the world of SMS.如果您知道服务提供商,只需使用电话号码和服务提供商电子邮件,这是进入 SMS 世界的后端方式。

Check it out: Email Service Providers for Texting Through Email检查一下: 通过电子邮件发送短信的电子邮件服务提供商

Use the HTML form for user info:使用 HTML 表单获取用户信息:

<p>Enter the Service Provider and the phone number to send a text right now!!</p>
<form action="current page or another, depending on structure" onsubmit="alert('Sent, it should be received shortly...');" method="post">
    <select name="inputMobileServiceProvider" required>
        <!--These are just some of them-->
        <option value="Verizon">Verizon</option>
        <option value="ATT">AT&T</option>
        <option value="TMobile">T-Mobile</option>
        <option value="Sprint">Sprint</option>
    </select>
    <input type="tel" name="inputMobileNumber" required />
    <input type="text" name="inputSubject" placeholder="Subject..." />
    <textarea name="inputMessage" required></textarea>
    <button>Send!!</button>
</form> 

And the PHP, whether it be on any page:还有 PHP,无论是在任何页面上:

<?php
    $inputServiceProvider = $_POST['inputMobileServiceProvider'];
    $inputMobileNumber = $_POST['inputMobileNumber'];
    $inputSubject = $_POST['inputSubject'];
    $inputMessage = $_POST['inputMessage'];

    if ($inputServiceProvider === "Verizon") {
        $serviceProvider = "@vtext.com";
    } elseif ($inputServiceProvider === "ATT") {
        $serviceProvider = "@txt.att.net";
    } elseif ($inputServiceProvider === "TMobile") {
        $serviceProvider = "@tmomail.net";
    } elseif ($inputServiceProvider === "Sprint") {
        $serviceProvider = "@messaging.sprintpcs.com";
    } else {
        echo "<script>alert('I\'m sorry but a Service Provider wasn't found, please try again!')</script>";
    }
    $searchArray = array(" ", "-", "(", ")", "+1")
    $inputMobileNumber = str_ireplace($searchArray, "", $inputMobileNumber);
    $recipientEmail = $inputMobileNumber + $serviceProvider
    mail($recipientEmail, $inputSubject, $inputMessage);
?>

And remember, this is just an example.请记住,这只是一个例子。 For production-use, use htmlspecialchars() and other security measures on the website.对于生产用途,请在网站上使用htmlspecialchars()和其他安全措施。 Also, make sure that there is a spam control.另外,请确保有垃圾邮件控制。 Your website might be in trouble if you mess with random SMS numbers, or if a user is spamming others.如果您乱用随机短信号码,或者如果用户向他人发送垃圾邮件,您的网站可能会遇到麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM