将小型vbscript xmlhttp转换为php?

将小型vbscript xmlhttp转换为php?,php,vbscript,Php,Vbscript,我有一个非常简单的xmlhttp代码段,需要将其转换为php。我在php方面绝对没有经验,所以我希望有人能帮我一把 以下是VBScript代码: dim xmlhttp set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP") xmlhttp.Open "GET","http://myurl.com/return.aspx?d=" & Request.QueryString("d"), false xmlhttp.send

我有一个非常简单的xmlhttp代码段,需要将其转换为php。我在php方面绝对没有经验,所以我希望有人能帮我一把

以下是VBScript代码:

dim xmlhttp 
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET","http://myurl.com/return.aspx?d=" & Request.QueryString("d"), false  
xmlhttp.send
Response.ContentType = "text/xml;charset=windows-1252"
Response.Write xmlhttp.responsetext
Set xmlhttp = nothing

我想你在找类似的东西

header('Content-type: text/xml; charset=windows-1252');
echo $result = file_get_contents("http://myurl.com/return.aspx?d=".$_GET["d"]);
对于卷曲备选方案:

header('Content-type: text/xml; charset=windows-1252');
$c = curl_init("http://myurl.com/return.aspx?d=".$_GET["d"]);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
echo $result = curl_Exec($c);

我绝对没有vbscript方面的经验,但我认为您要做的是获取特定的URL

以下是如何在php中实现这一点:

<?php
$r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
try {
    $r->send();
    if ($r->getResponseCode() == 200) {
        file_put_contents('local.rss', $r->getResponseBody());
        header('Content-type: text/xml; charset=windows-1252');
        echo $r->getResponseBody();
    }
} catch (HttpException $ex) {
    echo $ex;
}
?>
getResponseBody();
}
}捕获(HttpException$ex){
echo$ex;
}
?>

看看这里:

结果是服务器上禁用了文件获取内容,建议我改为使用“curl”——可能是因为安全问题?我试图简单地用“curl\u init”替换“file\u get\u contents”,但这不起作用。有什么想法吗?
<?php
$r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
try {
    $r->send();
    if ($r->getResponseCode() == 200) {
        file_put_contents('local.rss', $r->getResponseBody());
        header('Content-type: text/xml; charset=windows-1252');
        echo $r->getResponseBody();
    }
} catch (HttpException $ex) {
    echo $ex;
}
?>