【发布时间】:2013-05-23 21:30:45
【问题描述】:
我已经为此奋斗了好几个小时,现在我正试图从 maxhire 检索一个 rss 提要: rsslink,解析内容并使用jfeed显示。现在我知道ajax不允许跨域并且我一直在使用jfeed附带的proxy.php,但无济于事它只是告诉我url中有很多重定向所以我像这样增加了它们:
<?php
header('Content-type: text/html');
$context = array(
'http'=>array('max_redirects' => 99)
);
$context = stream_context_create($context);
// hand over the context to fopen()
$handle = fopen($_REQUEST['url'], "r", false, $context);
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?>
但仍然没有运气,它只是返回一条消息,告诉我该对象已被移动。所以我开始像这样使用 curl:
$ch = curl_init('http://www.maxhire.net/cp/?EC5A6C361E43515B7A591C6539&L=EN');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
var_dump($result);
在本地检索 xml 页面,但它只返回对象已移动的相同错误:
<body>string(237) "<title>Object moved</title>
<h2>Object moved to <a href="/cp/?EC5A6C361E43515B7A591C6539&L=EN&AspxAutoDetectCookieSupport=1&AspxAutoDetectCookieSupport=1">here</a>.</h2>
"
</body>
然后将我重定向到本地 url,并在末尾添加:&AspxAutoDetectCookieSupport=1。 有人可以解释一下我做错了什么吗?
【问题讨论】: