【问题标题】:SMS Gateway and API in phpphp中的短信网关和API
【发布时间】:2011-07-10 11:24:57
【问题描述】:

我试图在注册后通过短信发送用户凭据。网关可以通过 HTTP API 使用 GET 方法访问。所以我想将它集成到我的 registration_process.php 文件中,以便在输入详细信息后立即db 应该发送短信。

GET方法类似于

http://gatewayprovider?user=<username>&password=<password>&msg=<$my msg>&no=<$receiver no>

那么我如何在用户不知情的情况下调用这个 url。这是一种安全的方式

谢谢。

【问题讨论】:

  • 如果您使用某些网络托管服务托管您的网站。确保托管服务提供商允许您向另一台服务器发出请求。
  • 如果他们不这样做 - 更改主机。

标签: php get sms gateway


【解决方案1】:

您可以cURL,如果它已在网络服务器上安装并启用。

稍作修改example from php.net

$url = "http://gatewayprovider?user=".$username."&password=".$password."&msg=".$myMsg."&no=".$receiver_no;

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

当你说

这是一种安全的方式

我几乎无法相信以明文形式作为 http GET 请求发送数据是安全的。

数据对用户是不可见的,但任何嗅探您的数据的人都可以读取它。网关是否提供https?

同样使用GET发送数据,与POST相对的方法不是很安全,因为请求url会在日志中可见,考虑防火墙等等。这当然是在从您的服务器到短信网关的路由上。

如果您的短信网关支持,POST+HTTPS 将是最佳选择。 cURL 也是在这里使用的理想选择。

如果您没有安装 cUrl,您可以通过调用 shell 脚本来使用 wget。

【讨论】:

    【解决方案2】:

    有多种方法可以从 PHP 发出 HTTP 请求。 cURL 很受欢迎。

    【讨论】:

    • 难道不能有一个简单的解决方案,例如php header redirect但安全吗?
    • cURL 一个简单的解决方案。
    【解决方案3】:

    你也可以使用

    <?php
    $url = "http://gatewayprovider?user=<username>&password=<password>&msg=<$my msg>&no=<$receiver no>";
    $sendrequest = file_get_contents($url);
    ?>
    

    就是这样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-04
      • 1970-01-01
      • 2011-05-09
      相关资源
      最近更新 更多