0

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

GET 方法类似于

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

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

谢谢。

4

3 回答 3

3

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

来自 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 将在日志中可见,考虑防火墙等。这当然是在从您的服务器到 sms 网关的路由上。

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

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

于 2011-07-10T11:37:21.413 回答
0

有多种方法可以从 PHP 发出 HTTP 请求。cURL是一种流行的方法。

于 2011-07-10T11:27:48.003 回答
0

你也可以使用

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

而已。

于 2017-06-13T09:55:15.947 回答