0
我有捲曲的迴應:解析捲曲來獲取信息PHP
<html version="-//W3C//DTD XHTML 2.0//EN" xml:lang="en" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HEAD>
<TITLE>Request Error</TITLE>
</HEAD>
<BODY>
<DIV id="content">
<P class="heading1"><B>Error Status Code:</B> 'BadRequest'</P>
<P><B>Details: </B>Customer email address is not unique - [email protected]</P>
</DIV>
</BODY>
</html>
當我通過它的SimpleXMLElement轉換爲XML對象我無法訪問p標籤中的內容。有沒有一種快速的方法來獲得標題響應(400)或甚至更好的由cURL系統發送的信息。
我找回結果:
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSLCERT, SPEKTRIX_CERT);
curl_setopt($ch, CURLOPT_SSLKEY, SPEKTRIX_KEY);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'handleHeader');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'handleHeader');
curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w'));
$requestHeaders = array();
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
$result = curl_exec($ch);
感謝任何見解
謝謝。這確實給了我400響應,但有沒有什麼方法可以獲得信息'...客戶電子郵件....'而無需解析內容? – rmccallum 2012-04-26 10:22:57