通过PHP发出HTTPS请求并获得响应 [英] Make a HTTPS request through PHP and get response
本文介绍了通过PHP发出HTTPS请求并获得响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过PHP向服务器发出HTTPS请求并获得响应。
I want to make HTTPS request through PHP to a server and get the response.
类似于这个ruby代码
something similar to this ruby code
http = Net::HTTP.new("www.example.com", 443)
http.use_ssl = true
path = "uri"
resp, data = http.get(path, nil)
谢谢
推荐答案
这可能有效,请试一试。
this might work, give it a shot.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
了解更多信息,请查看
http://unitstep.net/blog/2009/05/05/using-curl-in -php-to-access-https-ssltls-protected-sites /
for more info, check http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
这篇关于通过PHP发出HTTPS请求并获得响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文