如果在网络服务器上安装并启用它,您可以使用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。