PHP中的短信网关和API

发布于 2024-11-19 05:10:18 字数 346 浏览 2 评论 0原文

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

GET 方法类似于

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

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

谢谢。

I'm trying to send user credentials via sms after registration.The gateway can be accessed using GET method via HTTP API.So I want to integrate it into my registration_process.php file so that as soon as the details are entered in db the sms should be delivered .

The GET method is similar to

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

So how can I call this url without any knowledge to the user. That is in a secure manner

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

兲鉂ぱ嘚淚 2024-11-26 05:10:18

如果网络服务器上已安装并启用了 cURL,则您可以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吗?

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

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

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

You can you cURL, if it is installed and enabled on the webserver.

Slightly modified 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);

When you say

That is in a secure manner

I can hardly believe sending the data in cleartext as a http GET request is safe.

The data will be invisble for the user, but anyone sniffing your data can read it. Does the gateway provide https?

Also sending data using GET, opposed to POST method is not really safe, since the request url will be visible in the logs, thinking of firewalls and so on. This is of course on the route from your server to the sms gateway.

If you SMS Gateway supports it, POST+HTTPS would be the best choice. cURL would also be an ideal choice to use here.

In case you dont have cUrl installed, you can use wget, by calling a shell script.

桃酥萝莉 2024-11-26 05:10:18

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

There are numerous ways to make an HTTP request from PHP. cURL is a popular one.

策马西风 2024-11-26 05:10:18

你也可以使用

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

就是这样。

you can also use

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

That's it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文