【发布时间】:2015-03-03 16:22:44
【问题描述】:
一直在尝试让一些 PHP cURL 代码工作,当你给它播客 URL 时,它会从 iTunes 获取 RSS 提要。代码如下:
$inputString = "curl -A 'iTunes/12.1.1.4 (Windows; U; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601) DPI/96' -s 'https://itunes.apple.com/podcast/id530114975'";
$input = shell_exec($inputString);
$dom = new DOMDocument();
$html = $dom->loadHTML($input);
使用 shell_exec 执行的 cURL 调用返回一个空白字符串。 当我调用 loadHTML 函数时,它会给出以下错误,这很明显,因为 cURL 调用没有返回任何内容.....
Warning: DOMDocument::loadHTML(): Empty string supplied as input in C:\php scripts\itunesFeedExtractor.php on line 130
现在,我从其他地方获得了 PHP cURL 代码,以前没有使用过它,并尝试对其进行修改以匹配我的计算机设置....我已经更改了 Windows 版本、服务包、版本号。 (不知道为什么需要 DPI/96 所以我不管它)
【问题讨论】:
-
有一个 PHP curl 扩展,你最好使用它。无需 shell exec curl。
-
尝试使用下面的 php curl 扩展,但仍然返回一个空字符串。想知道 curl 调用中的设置是否不正确?