【问题标题】:Getting an Error Message when Sending SMS using using PHP使用 PHP 发送 SMS 时收到错误消息
【发布时间】:2012-02-12 10:58:09
【问题描述】:

我的电脑上安装了一个短信服务器和一个连接到 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>

我的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,通常需要很长时间才能响应,最终出现此错误消息时:

警告:file(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 秒的最大执行时间

【问题讨论】:

  • 您说有一个登录页面,您必须先登录才能发送短信。您确定附加的登录名和密码正确吗?也许它希望您发送一个 cookie,而不是请求中的详细信息。如果您将$url 粘贴到浏览器中会发生什么情况(没有先登录)。
  • @AndrewR 感谢您的回复。如果我粘贴 URL,我的意思是 -> localhost:9333/ozeki?然后出现用户登录页面。谢谢:)
  • 是的,我已经检查了登录名和密码..它们都是正确的:)
  • 我的意思是,当您粘贴完整的 URL http://localhost:9333/ozeki?action=sendMessage&amp;login=admin&amp;password=abc123&amp;recepient=01672095631&amp;messageData=comp&amp;sender=01719349818 时会得到什么 - 它会发送您的消息吗?

标签: php sms sms-gateway


【解决方案1】:

尝试file_get_contents() 而不是 file()。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多