使用 PHP 脚本发送和接收短信?

发布于 2024-07-10 18:24:12 字数 203 浏览 6 评论 0原文

PHP 脚本(可与 MySQL DB 一起使用)是否可以使用某种服务器端解决方案发送和/或接收短信

需要任何特殊的服务器端应用程序或特殊的硬件吗? 以及兼容性? Windows,Linux?

Can a PHP script (which can be working with a MySQL DB) send and/or receive SMSs using some sort of server-side solution?

Any special server-side application, or special hardware required?
And compatibility? Windows, Linux?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

赴月观长安 2024-07-17 18:24:12

有很多像 Esendex 这样的公司提供用于发送/接收 SMS 消息的 API。 我不确定您是否想直接从您的硬件发送它们?

There are plenty of companies like Esendex that offer APIs for sending/receiving SMS messages. I'm not sure if you're looking to send them directly from your hardware though?

滿滿的愛 2024-07-17 18:24:12

您可以将 USB 连接到 gsm 调制解调器并从 php 或任何其他语言发送消息,或者您可以在手机上开发 J2EE 程序来执行相同的操作(这比较 hacker)。

最便宜的方法(至少这是我的经验)是花费 50 美元购买 MultiTech GSM 模块,安装一张具有无限文本的 GSM 卡并开始使用串行端口进行通信,非常简单的命令允许您发送文本和模块使所有协议连接和东西...

基本上你最终使用 AT 命令(它们从调制解调器更改为调制解调器),但它们就像 AT#T/"555031231" 示例文本消息 //

当然,使用 AT 命令的缺点GSM 芯片是你实际上必须做一些电子产品,如果你选择高端 GSM 调制解调器,它们已经解决了所有问题,你可以即插即用!

You can get usb to gsm modems and send messages from php or any other language or you can develope J2EE programs on cellphones to do the same thing(this is hackier).

The cheapest way to do it(at less that was my experience) was to get a MultiTech GSM module for 50 USD, installed a GSM card with unlimited text and started comunicating using the serial port, very simple commands allows you to send text and the module makes all the protocol conections and stuff...

Basicly you end up using AT commands (they change from modem to modem) but they are like AT#T/"555031231" Sample Text message //

Of course the down side of going with the gsm chip is that you actually have to do some electronics, if you go for the high end gsm modems they have all the solved and you can just plug and play!

笙痞 2024-07-17 18:24:12

如果您在英国,txtlocal 是一个不错的选择。 他们的网站上已经有示例代码来帮助您启动和运行。 很简单,使用curl函数。

http://www.txtlocal.co.uk/

If you are in the UK, txtlocal is a good option. They already have example code on their site to get you up and running. Very simple, using curl functions.

http://www.txtlocal.co.uk/

相思故 2024-07-17 18:24:12

发送短信

  1. 您的服务器上应安装 CURL。 (或者,您可以使用 php_file_get_contents 函数,但我推荐 CURL )
  2. 来自短信网关服务器提供商的短信 API。

这是一个使用 CURL 发送短信的简单函数:

function CURLsendsms($number, $message_body){
 $api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.'&message='.$textmessage;
 $smsGatewayUrl = "http://springedge.com";
 $smsgatewaydata = $smsGatewayUrl.$api_params;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_POST, false);
 curl_setopt($ch, CURLOPT_URL, smsgatewaydata);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $output = curl_exec($ch);
 curl_close($ch);
 // Use file get contents when CURL is not installed on server.
 if(!$output){
 $output =  file_get_contents($smsgatewaydata);  
 }
}

您也可以使用 php 类发送短信 http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

有上面的类中有两个文件:sendms.php - 调用短信网关restAPI 的类文件 test.php - 测试短信功能的示例文件。 此类使用 spring edge 短信网关提供商 API

要接收短信

您需要购买虚拟号码,可以是10位虚拟手机号码或短码号码。

虚拟号码可以使用 HTTP URL 进行配置,并将参数作为查询字符串

例如。 example.com/receivesms.php?from=%number%&smstext=%text%

在虚拟号码上收到的所有消息都将被触发到配置的 URL,以便您可以进一步处理它(例如,存储对数据库的回复或发送文本根据要求在脚本中添加消息响应)。

虚拟手机号码(2路短信号码)可以与任何短信服务提供商配置

To send sms:

  1. CURL should be installed on your server. (Alternatively you can use php_file_get_contents function but i recommend CURL )
  2. SMS API from sms gateway server provider.

Here is a simple function to send sms using CURL:

function CURLsendsms($number, $message_body){
 $api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.'&message='.$textmessage;
 $smsGatewayUrl = "http://springedge.com";
 $smsgatewaydata = $smsGatewayUrl.$api_params;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_POST, false);
 curl_setopt($ch, CURLOPT_URL, smsgatewaydata);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $output = curl_exec($ch);
 curl_close($ch);
 // Use file get contents when CURL is not installed on server.
 if(!$output){
 $output =  file_get_contents($smsgatewaydata);  
 }
}

Also you can use php class to send sms http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

There are two files in above class: sendsms.php - Class file to call sms gateway restAPI test.php - Example file to test sms function. This Class is using spring edge sms gateway provider API

To receive sms :

You need to purchase a virtual number which can be 10 digit virtual mobile number or short code number.

Virtual number can be configured with a HTTP URL with params as query string

Ex. example.com/receivesms.php?from=%number%&smstext=%text%

All the messages received on virtual number will be triggered to configured URL so you can process it further (Ex. Storing replies to DB or sending a text message in response) in your script as per requirement.

Virtual mobile number (2 way sms number) can be configured with any sms service provider

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文