使用 PHP 发送短信时收到错误消息
我的计算机上安装了短信服务器,并且 USB 端口连接了一个 gsm 调制解调器,因此,如果我在浏览器上点击 http://localhost:9333/ozeki?
,则会出现登录页面,之后我登录后有一个表格,我可以使用它向手机发送短信。这很好用。
现在,要从我的网络应用程序(将在本地主机上运行)发送短信,
我创建了一个表单,它看起来像下面的
<form name="form" action="send.php" method="post">
<table width="600" align="center" border="1">
<tr>
<td>Sender </td> <td> <input type="text" name="sender" /> </td>
</tr>
<tr>
<td>Recepient </td> <td> <input type="text" name="recepient" /> </td>
</tr>
<tr>
<td>Message </td> <td> <input type="text" name="message" /> </td>
</tr>
<tr>
<td colspan="2"> <input type="submit" name="submit" value="Send" /> </td>
</tr>
</table>
</form>
My send.php
$recepient=$_POST['recepient'];
$message=$_POST['message'];
$sender=$_POST['sender'];
$url='http://localhost:9333/ozeki?';
$url.="action=sendMessage";
$url.="&login=admin";
$url.="&password=abc123";
$url.="&recepient=".urlencode($recepient);
$url.="&messageData=".urlencode($message);
$url.="&sender=".urlencode($sender);
file($url);
现在问题是,当我单击提交按钮时,页面会转到 send.php,通常需要很长时间才能响应,当最终出现此错误消息时:
警告:文件(http://localhost:9333/ozeki?action=sendMessage&login=admin&password=abc123&recepient={my_number}&messageData=comp&sender={my_number}) [function.file ]:打开流失败:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机未能 回应。在第 14 行的 C:\xampp\htdocs\sms\send.php 中
致命错误:第 16 行的 C:\xampp\htdocs\sms\send.php 中超出了最大执行时间 60 秒
I have an sms server installed on my computer and a gsm modem attached to the usb port, so if I hit http://localhost:9333/ozeki?
on the browser a login page appears and after I log in there is a form using which I can send sms to mobile phones. This works fine.
Now to send sms from my web application(which will be running on localhost)
I have created a form and it looks like following
<form name="form" action="send.php" method="post">
<table width="600" align="center" border="1">
<tr>
<td>Sender </td> <td> <input type="text" name="sender" /> </td>
</tr>
<tr>
<td>Recepient </td> <td> <input type="text" name="recepient" /> </td>
</tr>
<tr>
<td>Message </td> <td> <input type="text" name="message" /> </td>
</tr>
<tr>
<td colspan="2"> <input type="submit" name="submit" value="Send" /> </td>
</tr>
</table>
</form>
My send.php
$recepient=$_POST['recepient'];
$message=$_POST['message'];
$sender=$_POST['sender'];
$url='http://localhost:9333/ozeki?';
$url.="action=sendMessage";
$url.="&login=admin";
$url.="&password=abc123";
$url.="&recepient=".urlencode($recepient);
$url.="&messageData=".urlencode($message);
$url.="&sender=".urlencode($sender);
file($url);
Now the problem is when I click on the submit button the page goes to send.php and usually it takes a lot of time to respond and when it finally does this error message appear:
Warning: file(http://localhost:9333/ozeki?action=sendMessage&login=admin&password=abc123&recepient={my_number}&messageData=comp&sender={my_number}) [function.file]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\sms\send.php on line 14
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\sms\send.php on line 16
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 file_get_contents() 而不是 file()。
Try file_get_contents() instead of file().