我正在尝试使用 Curl 将库存文件上传到亚马逊。我能够登录到我的帐户并进入库存上传页面,但似乎无法设置正确的路径,因为每次上传文件时,它都会指示从此上传处理的记录数 - 零。我想我走错了路。我正在使用“@/home/path-to-file/file-name.txt”我做错了什么?上传成功,但系统似乎找不到文件。
<?php
$URL = 'https://sellercentral.amazon.com/gp/item-manager/ezdpc/uploadInventory.html/ref=ag_invfile_mmap_home';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$page = curl_exec($ch);
$postFields['uploadType'] = 'PriceAndQty';
$postFields['uploadFileName'] = '@/home/path_to_file/inventory_file.txt';
$post = '';
foreach($postFields as $key => $value) {
$post .= $key . '=' . urlencode($value) . '&';
}
$post = substr($post, 0, -1);
curl_setopt($ch, CURLOPT_REFERER, $URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$page = curl_exec($ch); // make request