简体   繁体   English

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

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

I am from Romania and I am developing PHP Application for 1 year. 我来自罗马尼亚,并且正在开发PHP应用程序1年。 I want to build now a web application that sends sms from web using my phone number. 我现在想构建一个Web应用程序,使用我的电话号码从Web发送短信。 When the sms is send from the web, my sim card will be activated and will send that sms from my phone. 从网络上发送短信时,我的SIM卡将被激活,并将通过手机发送该短信。 Can you tell me please where to start with this? 你能告诉我从哪里开始吗? Thank you! 谢谢!

If you are using android you could use the ADB Driver, from the console you can run this (obviously with your phone connected) and send the SMS. 如果您使用的是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

You can save this in a script and then be called via PHP shell_exec () function through there and integrate everything you want to do. 您可以将其保存在脚本中,然后通过PHP shell_exec()函数调用该脚本,并集成您想要执行的所有操作。

Warning: extreme elegance ahead. 警告:超前的优雅。

If you want to be able to send SMS from PHP by using code as simple as: 如果您希望能够使用以下简单的代码从PHP发送SMS:

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

then you can immediately go to: https://github.com/evorion/SMSGateway 那么您可以立即转到: https : //github.com/evorion/SMSGateway

It's just incredibly easy to use and even works when your phone is not online the whole time. 它非常易于使用,甚至在您的手机始终不在线时也可以使用。

If your machine and android device are in same network you can try this 如果您的机器和android设备位于同一网络中,则可以尝试此操作

PHP side 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 side 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