[英]PHP Curl and XML Response - Updated
so after some great help, I've managed to get the script doing everything I need it to, but I need help with the next bit.所以在一些很大的帮助之后,我已经设法让脚本做我需要做的一切,但我需要下一点的帮助。
Please see my script below.请在下面查看我的脚本。 <?php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.xxxxx.com/webAPI/api/stock',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS =>'<?xml version="1.0" encoding="utf-8" ?>
<traderapi>
<token>T1a5c3t9</token>
<variant>Clearbank ltd</variant>
<pon>X</pon>
</traderapi>',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer T1a5c3t9',
'Content-Type: application/xml'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response
?>
I get the Picture of Chrome results我得到Chrome 结果的图片
The results that are displayed as this "210-AZBVTBC"显示为“210-AZBVTBC”的结果
However in the code show this (as per the picture) "210-AZBVTBC4"但是在代码中显示这个(根据图片)“210-AZBVTBC4”
You can see I do a simple echo $response.你可以看到我做了一个简单的 echo $response。 How do I parse the information so I can show and manipulate how I show the individual tags.
如何解析信息,以便显示和操作如何显示各个标签。 For example
例如
echo ''.$response->Sku.' echo ''.$response->Sku.'
'; ';
the result is a string not a file.结果是字符串而不是文件。 try using
simplexml_load_string
instead of simplexml_load_file
.尝试使用
simplexml_load_string
而不是simplexml_load_file
。
$Products = simplexml_load_string($response);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.