Home > Backend Development > PHP Tutorial > thinkphp5 - Urgent php sent xml cannot be parsed

thinkphp5 - Urgent php sent xml cannot be parsed

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-18 09:15:59
Original
2280 people have browsed it

thinkphp5 - Urgent php sent xml cannot be parsed

Response message body
thinkphp5 - Urgent php sent xml cannot be parsed

This is the request message body I sent via 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>
Copy after login
Copy after login

But it cannot be parsed. I don’t know where the problem lies. It always returns such a result.

The analysis result is as shown in the figure: (errorcode = 100) represents the error code

thinkphp5 - Urgent php sent xml cannot be parsed

The correct return result is like this. Here I only complete the parsing through form submission, which is normal.

thinkphp5 - Urgent php sent xml cannot be parsed

thinkphp5 - Urgent php sent xml cannot be parsed

I send an xml message locally but it cannot be parsed. Please help me!

Reply content:

thinkphp5 - Urgent php sent xml cannot be parsed

Response message body
thinkphp5 - Urgent php sent xml cannot be parsed

This is the request message body I sent via 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>
Copy after login
Copy after login

But it cannot be parsed. I don’t know where the problem lies. It always returns such a result.

The analysis result is as shown in the figure: (errorcode = 100) represents the error code

thinkphp5 - Urgent php sent xml cannot be parsed

The correct return result is like this. Here I only complete the parsing through form submission, which is normal.

thinkphp5 - Urgent php sent xml cannot be parsed

thinkphp5 - Urgent php sent xml cannot be parsed

I send an xml message locally but it cannot be parsed. Please help me!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template