Is there any way to get results of an Amazon MWS request in the Json or Xml format instead of a plain string?
my code is the following:
public function listOrders()
{
$request = "https://mws.amazonservices.it/Orders/2013-09-01?";
$request .= $this->getParameterString($this->parameters) . "&Signature=" . $this->calculateSignature($this->calculateStringToSign($this->parameters));
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// grab URL and pass it to the browser
$a = curl_exec($ch);
echo $a;
return $a;
}
when $a is shown I see this (a plain string with few possibilities of elaboration):
2016-11-21T22:59:59Z StandardOrder 2016-11-17T06:24:44Z 2016-11-17T18:47:54Z [email protected] 402-2385999-1452355 1 IT Std Domestic Shipped Amazon.it false 0 2016-11-25T22:59:59Z nico 2016-11-20T23:00:00Z EUR 199.00 false 2016-11-17T23:00:00Z APJ6JRA9NG5V4 MFN Other arezzo 3332260766 pratovecchio stia IT 52015 nico via ro 92/94/96 false Standard 2016-11-22T22:59:59Z StandardOrder 2016-11-19T18:35:43Z 2016-11-21T18:14:04Z [email protected] 171-6439117-6622751 1 IT Std Domestic Shipped Amazon.it false 0 2016-11-26T22:59:59Z s 2016-11-22T23:00:00Z EUR 130.00 false 2016-11-20T23:00:00Z APJ6JRA9NG5V4 MFN Other CA 3926624273 Cagliari IT 09126 Samuele civico 244 false Standard 2016-11-28T22:59:59Z StandardOrder 2016-11-24T11:30:20Z 2016-11-24T18:46:12Z [email protected] 404-3098817-1844319 1 IT Std Domestic Shipped Amazon.it false 0 2016-12-02T22:59:59Z ini 2016-11-27T23:00:00Z EUR 110.00 false 2016-11-24T23:00:00Z APJ6JRA9NG5V4 MFN Other latina 3286028770 terracina IT 04019 ...
but if I copy the $request in my browser, what I see is a XML format response.
how can I do?
$a
out to the browser, could it be that the browser is just hiding the xml tags? Did you view source? Or tryvar_dump($a)
? – Deatonhtmlentities
it will escape the HTML chars for you so you can see them the other option is to view source. – Savino