本文介绍了通过 PHP 发出 HTTPS 请求并得到响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 PHP 向服务器发出 HTTPS 请求并获得响应.

类似于这个 ruby​​ 代码的东西

 http = Net::HTTP.new("www.example.com", 443)http.use_ssl = 真路径 = "uri"resp, data = http.get(path, nil)

谢谢

解决方案

这可能有用,试一试.

$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);//设置使 curl_exec 返回结果而不是输出结果.curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//获取响应并关闭通道.$response = curl_exec($ch);curl_close($ch);

欲了解更多信息,请查看http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

I want to make HTTPS request through PHP to a server and get the response.

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)

Thanks

解决方案

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

for more info, checkhttp://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

这篇关于通过 PHP 发出 HTTPS 请求并得到响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 10:56