【发布时间】:2013-02-12 06:59:00
【问题描述】:
我正在使用 cURL 从外部域成功导入一些数据,直到我尝试使用此 URI:http://www.airbnb.com/calendar/ical/760186.ics?s=29623a93eb0e693c77591a711f082f06,这是一个 ics 日历。 我可以在命令行上成功运行它(自己试试): shell>> curl https://www.airbnb.com/calendar/ical/760660.ics?s=593cc556438a8f0919beb6107b6f508d,所以不是网络问题。
但我的 php 脚本(确实返回其他 URI)不返回这个。或者更好的是它返回 false。
这里是小php
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$ical1= "http://www.airbnb.com/calendar/ical/760186.ics?s=29623a93eb0e693c77591a711f082f06";
echo file_get_contents_curl($ical1);
我确实认为这与我的 apache 或 php 配置有关,因为它在 appfog 上运行,并且与我的旧 xampp 安装一起运行。 恢复:所有 URI 都使用旧的 xampp 安装,现在只有示例中的一个失败。
在我的 phpinfo() 上我可以阅读:
cURL support enabled
cURL Information 7.24.0
Age 3
Features
AsynchDNS Yes
Debug No
GSS-Negotiate Yes
IDN No
IPv6 Yes
Largefile Yes
NTLM Yes
SPNEGO No
SSL Yes
SSPI Yes
krb4 No
libz Yes
CharConv No
Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host i386-pc-win32
SSL Version OpenSSL/1.0.1c
ZLib Version 1.2.5
libSSH Version libssh2/1.3.0
【问题讨论】:
-
你得到什么错误信息?
-
两者都是下载文件的有效工具。如果你不说他们有什么问题,我们就无法提供替代方案。
-
您的日志/屏幕中是否有任何数据或错误?
-
函数返回false。
-
我发现这可能是一个 apache 问题......它在 appfog 上的工作就像一个魅力......