响应消息体
这是我通过PHP发送的请求消息体
<code><?php
public function getXml()
{
$xmlStr = <<<xml
<?xml version="1.0" encoding="utf-8"?>
<msg v="1.0" id="1470798667">
<ctrl><agentID>800205</agentID><cmd>2000</cmd><timestamp>1470798667</timestamp><md>17468b91d6b9bc1debb052a1f9a66fee</md></ctrl>
<body><loto lotoid="001" issue=""/></body></msg>
xml;
$url = 'http://175.25.25.41:7070/billservice/sltAPI';
$header[] = 'Content-type: text/xml; charset=utf-8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
$response = curl_exec($ch);
if(curl_errno($ch)){
print curl_error($ch);
}
curl_close($ch);
var_dump($response);
}</code>但是无法解析,不知道问题出在什么地方,始终返回这样的结果。
解析结果如图所示: (errorcode = 100)代表错误码
立即学习“PHP免费学习笔记(深入)”;
正确的返回结果,是这样的。此处我只通过表单提交完成解析,是正常的。
我在本地发送xml消息 始终无法解析 求助各位大神们!
响应消息体
这是我通过PHP发送的请求消息体
<code><?php
public function getXml()
{
$xmlStr = <<<xml
<?xml version="1.0" encoding="utf-8"?>
<msg v="1.0" id="1470798667">
<ctrl><agentID>800205</agentID><cmd>2000</cmd><timestamp>1470798667</timestamp><md>17468b91d6b9bc1debb052a1f9a66fee</md></ctrl>
<body><loto lotoid="001" issue=""/></body></msg>
xml;
$url = 'http://175.25.25.41:7070/billservice/sltAPI';
$header[] = 'Content-type: text/xml; charset=utf-8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
$response = curl_exec($ch);
if(curl_errno($ch)){
print curl_error($ch);
}
curl_close($ch);
var_dump($response);
}</code>但是无法解析,不知道问题出在什么地方,始终返回这样的结果。
解析结果如图所示: (errorcode = 100)代表错误码
立即学习“PHP免费学习笔记(深入)”;
正确的返回结果,是这样的。此处我只通过表单提交完成解析,是正常的。
我在本地发送xml消息 始终无法解析 求助各位大神们!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号