我们有一个flash开发人员使用调用一个名为proxy.php的文件与querystring?url =“http:// feedburner/whatever”来访问来自不是默认从swf代码访问的域的rss提要的外部数据。例如,我可以在浏览器中使用以下内容:http://localhost/proxy.php?url=feedburner.com/a_feed并且浏览器将显示页面,就好像我将feedburner网址直接放在浏览器地址栏中一样。这个proxy.php文件中的PHP代码如下。ASP.NET等价于此PHP代码?
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);
$ch = curl_init($_GET['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if (strlen($post_data)>0){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
//$response=split("iso-8859-2",$response);
//$response=join("UTF-8",$response);
print $response;
}
它工作正常,但由于主机的限制,我们需要在asp.net中复制功能。我不知道PHP,尽管努力去理解我失败的代码。我需要能够复制我在第一段中用asp.net描述的功能,但是尽管使用Google搜索器中的XmlTextWriter使用Google搜索技术,但我失败了。我在这里错过了什么?
我猜response.redirect不会工作,因为它告诉源去外部域本身,我们想要避免这一点。
我该如何在ASP.NET中实现这个PHP代码功能?
看看这里:http://www.php.net/manual/en/ref.curl.php – 2010-02-22 19:19:19
通用一个,任何语言将被调用命令行卷曲。 – takeshin 2010-11-17 22:18:07