简体   繁体   English

SSI的问题包括PHP file_get_contents()和https

[英]Problem with SSI includes, PHP file_get_contents() and https

I have a script that pulls a file's contents and then echos it out like so: 我有一个脚本,可以提取文件的内容,然后像这样回显它:

$file_to_read = "http://website.com/" . $file_name;
$text = @file_get_contents($file_to_read);
echo $text;

This is the way I've done it, because the files getting read have SSI includes and once echoed would not work. 我就是这样做的,因为要读取的文件包含SSI,并且一旦回显就行不通。

Now I need to replicate the code but call the same website with https and it's not working. 现在,我需要复制代码,但使用https调用同一网站,但无法正常工作。 Does anyone have a suggestion on how to do the same thing, but have it work while calling an https URL or using a local path? 有没有人对如何做同样的事情有任何建议,但是在调用https URL或使用本地路径时可以起作用吗?

Thanks! 谢谢!

I have had more luck with using cURL as opposed to file_get_contents, here is what I use for my facebook api calls that include an access_token (only available on secure connections): 与使用file_get_contents相比,我更喜欢使用cURL,这是我用于包含access_token的facebook api调用的内容(仅在安全连接上可用):

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$file_to_read);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
$text = curl_exec($curl_handle);
curl_close($curl_handle);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM