PHP Classes

upload image to etsy

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  upload image to etsy  >  (Un) Subscribe thread alerts  
Subject:upload image to etsy
Summary:cant upload image to etsy listing
Messages:4
Author:Sagar Patil
Date:2015-11-24 05:31:19
 

  1. upload image to etsy   Reply   Report abuse  
Picture of Sagar Patil Sagar Patil - 2015-11-24 05:31:19
I am trying to upload image file fot etsy listing,
for this I provide image from remote url
$paramList=array();
$paramList['image'] = file_get_contents("http://thumbs2.sandbox.ebaystatic.com/pict/110159584005404000000001_1.jpg");

and I did api call as

$this->client->ResetAccessToken();
$success = $this->client->CallAPI('https://openapi.etsy.com/v2/listings/256722957/images','POST',$paramList['image'],array('FailOnAccessError'=>true,'Files'=>array('image'=>array('ContentType'=>'image/jpeg'))), $return);

returns blank responce

no image gets uploaded.
Is I am missing somthing?


  2. Re: upload image to etsy   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-11-24 05:44:09 - In reply to message 1 from Sagar Patil
This is not a very good script.

You cannot Reset the token before making an API call. So, do not throw random code when you are not sure what you are doing.


Your API call should be something like this, but you need to have the calls to Initalize and Finalize as in the examples.

$success = $client->CallAPI(
"https://openapi.etsy.com/v2/listings/256722957/images",
'POST', array(
'image' => 'http://thumbs2.sandbox.ebaystatic.com/pict/110159584005404000000001_1.jpg'
),array(
'FailOnAccessError'=>true,
'Files'=>array(
'image'=>array(
)
)
), $upload);

  3. Re: upload image to etsy   Reply   Report abuse  
Picture of Sagar Patil Sagar Patil - 2015-11-25 08:22:56 - In reply to message 2 from Manuel Lemos
Thanks for the example code ,
this works when I give local file path but not with remote image url.
ex-
$imageSource = 'E:\testimage.jpg';
client->CallAPI("https://openapi.etsy.com/v2/listings/".$listingId."/images",'POST', array('image' =>$imageSource),array('FailOnAccessError'=>true,'Files'=>array('image'=>array())), $uploadResult);

works

$imageSource = 'https://img1.etsystatic.com/131/0/11919855/il_170x135.874878141_6l9n.jpg';
client->CallAPI("https://openapi.etsy.com/v2/listings/".$listingId."/images",'POST', array('image' =>$imageSource),array('FailOnAccessError'=>true,'Files'=>array('image'=>array())), $uploadResult);

does not.

why it is so?


  4. Re: upload image to etsy   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-11-25 17:23:33 - In reply to message 3 from Sagar Patil
It should give you an error message. Check the class $error variable.