我使用我发现和修改的脚本在过去几周内从iTunes App Store中提取信息.一切都运行正常,直到几天前我意识到不再生成XML了.以下是生成XML的脚本的代码:
header("Content-type: text/plain");
ini_set('display_errors', false);
if(isset($_GET['appID']))
{
$appID = (int)stripslashes($_GET['appID']);
$url = "http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=" . $appID . "&mt=8";
$useragent = "iTunes/9.0.2 (Macintosh; Intel Mac OS X 10.5.8) AppleWebKit/531.21.8";
$header = array("X-Apple-Store-Front: 143441-1");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
}
?>
所以我添加了HTTPHEADER选项无济于事,但是当我去Terminal并输入以下内容时,它的效果非常好:
curl -s -A "iTunes/9.0.2 (Macintosh; Intel Mac OS X 10.5.8) AppleWebKit/531.21.8" -H "X-Apple-Store-Front: 143441-1" 'http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=339038562&mt=8'
它返回我需要的XML,但为什么PHP脚本不能工作呢?
感谢任何帮助!