Hey everyone!
I am trying to post a feed file to ebay from our site via a PHP script, but I am new to this stuff and having some trouble. On ebay's website they have an example of the request you need to send to post a feed file:
POST /path/to/upload/script HTTP/1.0
Connection: Keep-Alive
User-Agent: My Client App v1.0
Host:
https://bulksell.ebay.com/ws/eBayISA...ExchangeUpload
Content-type: multipart/form-data;
boundary=THIS_STRING_SEPARATES
Content-Length: 256
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="token"
12345678987654321
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file";
filename="listings.csv"
Content-Type: text/csv
... contents of listings.csv ...
--THIS_STRING_SEPARATES
I tried to implement it using this code:
PHP Code:
<?php
// GET THE FEED FILE
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "website",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_TIMEOUT => 120,
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER => false,
);
$ch = curl_init('https://www.mysite.com/pull_feed.php');
curl_setopt_array( $ch, $options );
$contents = curl_exec( $ch );
curl_close( $ch );
//----------------------------------------------------//
//OPEN THE CONNECTION
$conn = fsockopen('https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeProgrammaticDownload', 80);
// START THE REQUEST
fputs($conn, "POST ".$_SERVER['PATH_INFO']." HTTP/1.0");
fputs($conn, "Connection: Keep-Alive");
fputs($conn, "User-Agent: My Client App v1.0");
fputs($conn, "Host:");
fputs($conn, "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload");
fputs($conn, "Content-type: multipart/form-data;");
fputs($conn, "boundary=THIS_STRING_SEPARATES");
fputs($conn, "Content-Length: ".strlen($contents));
fputs($conn, "--THIS_STRING_SEPARATES");
fputs($conn, "Content-Disposition: form-data; name=\"token\"");
fputs($conn, "MY_KEY_IS_HERE_000000000000000000000000");
fputs($conn, "--THIS_STRING_SEPARATES");
fputs($conn, "Content-Disposition: form-data; name=\"file\";");
fputs($conn, "filename=\"listings.csv\"");
fputs($conn, "Content-Type: text/csv");
// SEND THE FILE
fputs($conn, $contents);
// END THE REQUEST
fputs($conn, "--THIS_STRING_SEPARATES");
// GET THE RESULT
while(!feof($conn)) {
echo fgets($conn, 128);
}
// CLOSE CONNECTION
fclose($conn);
?>
But I am getting this error:
Warning: fsockopen() [function.fsockopen]: unable to connect to
https://bulksell.ebay.com/ws/eBayISA...ticDownload:80 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in C:\home\imafs\public_html\funad\ebay\send_feed.php on line 27
Followed by more errors resulting from that one.
What can I do to solve this? Or is there another way to go about this?
Bookmarks