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

时间:2015-04-27 12:34:11

标签: php web sms

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

3 个答案:

答案 0 :(得分:2)

如果您使用的是Android,您可以使用ADB驱动程序,您可以在控制台上运行它(显然连接了手机)并发送短信。

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()函数调用,并集成您想要执行的所有操作。

答案 1 :(得分:0)

警告:前方极端优雅。

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

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

然后您可以立即转到:https://github.com/evorion/SMSGateway

它非常容易使用,甚至可以在手机不在线时使用。

答案 2 :(得分:0)

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

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();