我尝试将CSV文件发送到eBay FileExchange Service。
我正在编写一个应用程序以同时更新eBay上的许多产品。当我使用eBay CSV管理器上传test.csv时,更新将成功,但是使用脚本后,发布数据后将不会发生任何事情。
我已经完成以下步骤:
为FileExchange创建单独的令牌。https://signin.ebay.de/ws/eBayISAPI.dll?SignIn&runame=F-FILEEXL51P1EHH6L899Q9B969GE134DK-FileUpload
然后我使用以下脚本:
$token = 'AgAAAA**AQAAAA**aAAAAA************';
$ebay_url = 'https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload';
$sendheaders = array(
'User-Agent: My Client App v1.0'
);
$fields = array(
'token' => $token,
'file' => '@test.csv'
);
$ch = curl_init($ebay_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_NOBODY, 0); // set to 1 to eliminate body info from response
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); // use HTTP/1.0 instead of 1.1
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendheaders);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // use HTTP POST to send form data
$resp = curl_exec($ch); //execute post and get results
if(!curl_exec($ch)) {
die('Error: ' . curl_error($ch) . ' - Code: ' . curl_errno($ch));
}
curl_close ($ch);
我已使用此csv文件格式(test.csv)
Action; ItemID; DispatchTimeMax修订; 28 ********* 916; 30
发布后的结果:
print_r($ resp);
HTTP / 1.1 200确定伺服器:Apache-Coyote / 1.1Set-Cookie:dp1 = bu1p / QEBfX0BAX19AQA ** 617d3da3 ^ bl / DE617d3da3 ^; Domain = .ebay.com;过期时间= 2021年10月30日星期六,格林尼治标准时间;路径= /Set-Cookie:s = CgAD4ACBdvCgjMjFkNjZkMDcxNmUwYTBmMTc1MTA0ZmEwZmZmYjEyZWFY39RE; Domain = .ebay.com;路径= /Set-Cookie:nonsession = CgADKACBhfT2jMjFkNjZkMDcxNmUwYTBmMTc1MTA0ZmEwZmZmYjEyZWIAywABXbrdqzHTwXKU; Domain = .ebay.com;过期时间= 2021年10月30日星期六,格林尼治标准时间;路径= /缓存控制:私有语法:无缓存内容类型:text / html; charset = UTF-8内容长度:731日期:2019年10月31日星期四12:42:11 GMT连接:保持活动状态
文件上传成功。您的参考号是。关闭
感谢您的帮助。
我找到了解决方法:
显然在php 7.1,@无效,并且文件邮寄给ebay空。
我使用curl_file_create函数,它起作用了。
if (!function_exists('curl_file_create'))
{
function curl_file_create($filename, $mimetype = '')
{
return "@$filename;filename="
. ($mimetype ? ";type=$mimetype" : '');
}
}
$fields = array(
"token" => $token,
"file" => curl_file_create ($_GET['filename'], 'text/csv')
);
希望有帮助的人。