2012-03-06 5 views
0

私はPHPに変換する必要がある非常に単純なxmlhttpスニペットを持っています。私はPHPで全く経験がないので、私は誰かが私に手を貸してくれることを望んでいた。ここで小さいvbscript xmlhttpを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 

答えて

0

私はあなたがCURL代替のため

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); 
+0

それは、のfile_get_contentsがサーバー上で無効であることが判明し、それは私が「カール」を使用することをお勧めします代わりに - 主にセキュリティの問題のために?私は単に "file_get_contents"を "curl_init"に置き換えようとしましたが、うまくいきません。何か案は? – brother

+0

@brother:あなたの要求を反映するために私の質問を編集 –

+0

魅力的なように働いた - thx! :)(ちょうどecho $ resultを追加しました) – brother

0
header('Content-type: text/xml; charset=windows-1252'); 
echo file_get_contents('http://myurl.com/return.aspx?d=' . $_GET['d']); 
1

私はabsolutly持っていますvbscriptで0回の経験があると思います特定の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; 
} 
?> 

はこちらをご覧:http://php.net/manual/en/httprequest.send.php

関連する問題