1

Been trying to get the item report csv file using walmart api but no luck, Instead get this unreadable response. Need help. How can I make this work?

Here's the screenshot of the response :

cURL GET Response

Here's my code :

$walmart_consumer_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$walmart_channel_type = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$dtd = date("Y_m_d");

$request_type = "GET";

$url = "https://marketplace.walmartapis.com/v2/getReport?type=item";

// We need a timestamp to generate the signature and to send as part of the header
$timestamp = round(microtime(true) * 1000);

$signature = getClientSignature($url, $request_type, $timestamp);

$headers = array();
$headers[] = "Accept: application/xml";
$headers[] = "WM_SVC.NAME: Walmart Marketplace";
$headers[] = "WM_CONSUMER.ID: ".$walmart_consumer_id;
$headers[] = "WM_SEC.TIMESTAMP: ".$timestamp;
$headers[] = "WM_SEC.AUTH_SIGNATURE: ".$signature;
$headers[] = "WM_QOS.CORRELATION_ID: ".mt_rand();
$headers[] = "WM_CONSUMER.CHANNEL.TYPE: " .$walmart_channel_type;
$headers[] = "Content-type: text/";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_type);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

var_dump($result);
Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68
Toffer
  • 79
  • 2
  • 12

1 Answers1

0

Looks like the response is in ZIP format; notice the first two characters in the results is "PK" -- that is magic saying it is in zip format. Probably be an option in curl to decode ZIP format.

Mark Stewart
  • 2,046
  • 4
  • 22
  • 32
  • How to read the csv file inside the zip so i can process that data? – Toffer Jun 13 '18 at 20:04
  • Sorry; I'm not familiar enough with curl and php; I just know a ZIP file when I see one in a hex dump, and know most web sites delivery their content in zip format to save space and network time. – Mark Stewart Jun 14 '18 at 14:26