一直试图使用 walmart api 获取项目报告 csv 文件但没有运气,而是得到这个不可读的响应。需要帮忙。我怎样才能使这项工作?
这是响应的屏幕截图:
这是我的代码:
$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);