目前,我正在用PHP编写文章/客户/计费软件,这是让我的合作伙伴测试它之前的最后一步。
我现在真的被困住了。我们希望将文章自动上传到eBay。文件交换程序的CSV文件的生成很好,手动上传也很好,文章将被列出。
现在我们希望软件自己来做上传。我们在这里参考eBay文件交换指南:

在这里:

。
这是我现在的代码:
$SOCKETPROC = fsockopen('bulksell.ebay.de', 80, $errno, $errstr, 4);
fputs($SOCKETPROC, "POST https://bulksell.ebay.de/ws/eBayISAPI.dll?FileExchangeUploadForm HTTP/1.0\r\n");
fputs($SOCKETPROC, "Connection: Keep Alive\r\n");
fputs($SOCKETPROC, "User-Agent: App v1.0\r\n");
fputs($SOCKETPROC, "Host: https://bulksell.ebay.de/ws/eBayISAPI.dll?FileExchangeUpload\r\n");
fputs($SOCKETPROC, "Content-Type: multipart/form-data; boundary=THIS_STRING_SEPARATES\r\n");
fputs($SOCKETPROC, "Content-Length: " . filesize('export/ebay/items-' . date('Y-m-d') . '.csv') + filesize('export/ebay/token') . "\r\n");
fputs($SOCKETPROC, "--THIS_STRING_SEPARATES\r\n");
fputs($SOCKETPROC, "Content-Disposition: form-data; name=\"token\"\r\n");
fputs($SOCKETPROC, file_get_contents('export/ebay/token'));
fputs($SOCKETPROC, "\r\n--THIS_STRING_SEPARATES\r\n");
fputs($SOCKETPROC, "Content-Disposition: form-data; name=\"file\"; filename=\"items-" . date('Y-m-d') . ".csv\"\r\n");
fputs($SOCKETPROC, "Content-Type: text/csv\r\n\r\n");
fputs($SOCKETPROC, file_get_contents('export/ebay/items-' . date('Y-m-d') . '.csv'));
fputs($SOCKETPROC, "\r\n--THIS_STRING_SEPARATES\r\n");
fputs($SOCKETPROC, "Connection: Close\r\n\r\n"); // Not sure if this line is relevant
$RESULT = fgets($SOCKETPROC);
fclose($SOCKETPROC);但是文件不会出现在上传文件的eBay列表中。当我将https://更改为http://并使用fgets($SOCKETPROC);检查结果时,我将得到一个HTTP/1.1 200 OK,否则不会有任何反应。
注:.de是故意使用的。所以这里没有错误和错误。
发布于 2012-09-01 01:49:33
尝试通过cUrl连接和上传:
$token = "your_token";
$ebay_url = "https://bulksell.ebay.de/ws/eBayISAPI.dll?FileExchangeUpload";
$sendheaders = array(
"User-Agent: MyClient v1.6",
);
$fields = array(
"token" => $token,
"file" => "@file.csv"
);
$ch = curl_init($ebay_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // 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
curl_close ($ch);https://stackoverflow.com/questions/9812111
复制相似问题