question

empiretimenyc avatar image
0 Likes"
empiretimenyc asked

I am trying to upload csv file to eBay using PHP curl and no error is coming but I am not able to see the uploaded file

hi,

I am using feed api after creating Task and getting the response


HTTP/1.1 200 OK rlogid: t6pitaf%60btuf1%3D9vjdpitaf%60btuf1*6q%7Cj5%28rbpv6775-17d09c39455-0x2343 content-length: 0 date: Wed, 10 Nov 2021 12:12:31 GMT x-envoy-upstream-service-time: 2 server: ebay-proxy-server x-ebay-pop-id: UFES2-SLCAZ01-api


but Can't find the uploaded file, kindly let me know if I am getting any error also where I an see my uploaded file....


Using below Code


function createTask($feedType='FX_LISTING',$token)

{

$link = "https://api.ebay.com/sell/feed/v1/task";

//$appConfig = parse_ini_file("config.ini");

//echo $token;

//payload

$payload = json_encode(array("schemaVersion"=>"1.0","feedType"=>"FX_LISTING"));

//$appConfig['user_token'] = 'mehboob';

$ch = curl_init($link);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

'Authorization:Bearer ' . $token,

'Accept:application/json',

'Content-Type:application/json',

'X-EBAY-C-MARKETPLACE-ID: EBAY_US'

));

curl_setopt($ch, CURLHEADER_SEPARATE, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_HEADER, 1);

//scurl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');

curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

$response = curl_exec($ch);

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

$headers = substr($response, 0, $header_size);

$body = substr($response, $header_size);

$info = curl_getinfo($ch);

// echo($body);

curl_close($ch);

$headers = explode("\r\n", $headers);

$headers = array_filter($headers);

$loc = basename(implode(preg_grep("/^location.*/", $headers)));

return $loc;

}



function uploadFile($taskID, $fName,$token)

{

$curl = curl_init();



//$newnm="https://empire.idiamondcloud.com/JewelAct/ebay_api/".$fName;

$newnm=realpath($fName);

$cfile = new CurlFile($newnm, 'text/csv');

//echo filesize($newnm);

//curl file itself return the realpath with prefix of @

$data = array('data-binary' => $cfile);

curl_setopt_array($curl, array(


CURLOPT_URL => 'https://api.ebay.com/sell/feed/v1/task/'.$taskID.'/upload_file',


CURLOPT_RETURNTRANSFER => true,


CURLOPT_ENCODING => '',


CURLOPT_MAXREDIRS => 100,


CURLOPT_SSL_VERIFYHOST=> 0,


CURLOPT_SSL_VERIFYPEER=> 0,


CURLOPT_TIMEOUT => 0,


CURLOPT_HEADER => 1,


CURLOPT_FOLLOWLOCATION => true,


CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,


CURLOPT_CUSTOMREQUEST => 'POST',


CURLOPT_POSTFIELDS => $cfile,


CURLOPT_HTTPHEADER => array(


'Authorization: Bearer '.$token,


'X-EBAY-C-MARKETPLACE-ID: EBAY_US'



),


));




$response = curl_exec($curl);

echo "<pre>";

print_r($response);

echo "</pre>";

curl_close($curl);

}


feed-apicsvfile-upload#error
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.