I am using the Amazon AIMS API to load an inventory file, and I had a problem calling cURL to load the file. The documentation is very limited, so there is no sample code that helps with this.
This is what I still called cURL:
$inventory = fopen($FILENAME, 'r') or die("Can't open file!");
echo $inventory;
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_INFILE, $inventory);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filename));
curl_setopt($ch, CUROPT_PUT, TRUE);
$response = curl_exec($ch);
curl_close($ch);
I tried putting $ inventory in CURLOPT_POSTFIELDS and not have INFILE, but I get the same error.
In the XML response, I get a " NO_FILE_ATTACHED", so the obvious problem is attaching the file to the XML call.
I also tried loading, as the first responder said, using example # 2 on the curl_setopt page on php.net.
For this, I used the following code:
$data = array('@/tmp/amazon_export.csv');
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
I got the same answer NO_FILE_ATTACHED.
Any ideas?