繁体   English   中英

Web应用程序从我的手机发送短信吗?

[英]Web application send sms from my mobile phone?

我来自罗马尼亚,并且正在开发PHP应用程序1年。 我现在想构建一个Web应用程序,使用我的电话号码从Web发送短信。 从网络上发送短信时,我的SIM卡将被激活,并将通过手机发送该短信。 你能告诉我从哪里开始吗? 谢谢!

如果您使用的是android,则可以使用ADB驱动程序,您可以从控制台运行它(显然已连接手机)并发送SMS。

adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22
adb shell input keyevent 66

您可以将其保存在脚本中,然后通过PHP shell_exec()函数调用该脚本,并集成您想要执行的所有操作。

警告:超前的优雅。

如果您希望能够使用以下简单的代码从PHP发送SMS:

mail('0981234567@catchall.domain.com', '', 'SMS Message here'); // PHP

那么您可以立即转到: https : //github.com/evorion/SMSGateway

它非常易于使用,甚至在您的手机始终不在线时也可以使用。

如果您的机器和android设备位于同一网络中,则可以尝试此操作

PHP方面

$client = new SMSClient();

try{

$exampleIP = "10.0.0.1";
$examplePort = 1234;

$client->connectToSMSServer($exampleIP, $examplePort);

}catch(Exception $e)
{
    echo "error! ".$e->getMessage();
    die();
}

$exampleMobileNo = "123456789"; // mobile phone no
$exampleMessage = "hello...";   // text message

//Make sure to validate Mobile No using regular expression. If invalid mobilePhoneNo then do other stuff


//If phone no is OK then 
$client->setMobileNo($exampleMobileNo);
$client->setSmsText($exampleMessage);
$error = $client->send();

Android方面

SMSServer smsServer = new SMSServer(getApplicationContext(),1234);

//To start
smsServer.start();
..
..
..
//To stop
smsServer.stopSMSServer();

暂无
暂无

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

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