0
我想提出一個簡單的PHP REST服務,我打電話,捲曲這裏這項服務是該如何使PHP REST服務器發送效應初探回客戶端
//client code example
$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
現在對REST服務我收到的代碼請求並執行任務。然後我必須將回復發送回去。
//server code example
$xml_post = file_get_contents('php://input');
$xmlparser = new XMLParser;
$parsedata = $xmlparser->parse($xml_post);
$resultobj = new ResultGenerate;
$result = $resultobj->generate($parsedata);
我不知道如何發送reponse($ result)back.So那$輸出在最後有xml字符串。請幫忙