我使用PHP http_post_data()调用将数据发送到一个CakePHP的controller.I做这样的:从http_post_data提取响应主体在PHP
$response=http_post_data($url, $xml_data_encoded);
数据到达确定的目标和我一个响应持有的响应状态。在我的情况下,状态是数字1,这意味着-data交付ok.As你可以从下面的代码中看到我不仅获得状态号码(这是在消息的底部),但也整个http post header.How我可以从标题代码剥离此消息,以便最终响应消息只包含状态号?
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Thu, 10 Nov 2011 08:34:15 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.3
Set-Cookie: CAKEPHP=xxxxxxxxxxxxxxxx; expires=Fri, 18-Nov-2011 16:34:15 GMT; path=/XXXXXXXXXX/xxxxxxxx
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Vary: Accept-Encoding
Content-Length: 19
Content-Type: text/html
1
顺便说一句,我也试过这样:
HttpMessage::getBody(http_post_data($url, $xml_data_encoded));
,并没有得到回应的。 任何帮助将不胜感激。
你只想要'1'在底部? – Mob
这是正确的。 –