1
我測試兩個文件之間的XML POST:PHP的XML響應沒有出現在捲曲請求
的index.php,其寫出一個簡單的XML頁面。當我打開 'send.php'
send.php,它發送一個捲曲POST到的index.php並期望XML響應
,會出現問題 - 從所述的index.php XML不是寫入頁面。我懷疑我沒有正確寫出XML,但可以真正使用一些指導。我的代碼如下:
// send.php
$url_request = 'index.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url_request);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($response);
print_r($xml);
// index.php
header("Content-type: text/xml");
function sendResponse(){
$response = '<?xml version="1.0" encoding="utf-8"?><response>success</response>';
echo $response;
}
sendResponse();
謝謝@KAD,那就是訣竅。非常感激。 – fireinspace
不客氣,老兄 – KAD