有些学建网站的学员使用Discuz建论坛网站时,遇到一个问题,在HTTP站点时UCenter通信是正常的,但启用了HTTPS站点后,UCenter通信失败。(相关教程:如何将HTTP网站域名转换成HTTPS)如下图:
出现HTTPS站点UCenter通信失败的原因是由于301重定向https后通信失败的。下面介绍一下解决方法。
$port = !empty($matches['port']) ? $matches['port'] : 80;
if(substr($url,0,5)=='https'){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
return curl_exec($ch);
}