我可以發送GET
請求並在以下行接收響應。如何解析Curl響應?
$curl_resp = curl_exec($curl);
我用下面的解析響應,但它不工作,我已經手動設置一些值$curl_resp
但仍然不知道如何單獨訪問xml
的每個變量的值。
$xml = simplexml_load_string($curl_resp);
注:我recevice實際的XML,但不能分析它,(我需要在一個變量分別獲得每個標籤的價值)
代碼:
<?php
$service_url = ' The Url goes here';
$curl = curl_init($service_url);
$curl_post_data = array(
"PASSWORD" => 'pass',
"USERNAME" => 'username'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_resp = curl_exec($curl);
curl_close($curl);
會發布你的整個代碼? –
是否設置了CURLOPT_RETURNTRANSFER選項? –
沒有足夠的信息(例如:源代碼),不能幫你OP。 –