logical-and / php-oauth

Support for authenticating users (without dep from any framework) using both OAuth1 and OAuth2 methods
https://packagist.org/packages/and/oauth
MIT License
43 stars 13 forks source link

Request for example of uploading image to Etsy #26

Open ipsod opened 9 years ago

ipsod commented 9 years ago

I've not used your package, but its predecessor. I was able to list an item on etsy, but failed to upload an image to an etsy listing. Would you please write an example of an etsy image upload?

logical-and commented 9 years ago

To save a time, post please details about Etsy image uploading.

ipsod commented 9 years ago

It's a bit of a pain to set up, since you (seemingly) first have to create a shipping template, then create a listing using that shipping template's id, then upload an image to the listing. Here's a link to Etsy's documentation:

ShippingTemplate https://www.etsy.com/developers/documentation/reference/shippingtemplate#method_createshippingtemplate

Listing https://www.etsy.com/developers/documentation/reference/listing#method_createlisting

ListingImage https://www.etsy.com/developers/documentation/reference/listingimage#section_uploading_images

Here's the array I used for creating a listing - could save you some keystrokes:

$fields = array(
        'quantity' => (integer) 1,
        'title' => 'Product',
        'state' => 'draft',
        'description' => 'Testing description.',
        'price' => (float) 42.42,
        'materials' => array('glass'),
        'shipping_template_id' => (integer) $shipping_template_id,
        //'shop_section_id' => null,
        //'is_customizable' => null,
        //'non_taxable' => null,

        //'image_ids' => null,
        //'image' => null,
        'processing_min' => 1,
        'processing_max' => 3,
        'category_id' => 68890894, // art and collectibles / glass art / sculptures and figurines
        'taxonomy_id' => 2889, // art and collectibles / glass art / sculptures and figurines
        'tags' => 'glass,marble,lampwork,bead', // validate using regex pattern: /[^\p{L}\p{Nd}\p{Zs}\-'™©®]/u 
        'who_made' => 'i_did',
        'is_supply' => (boolean) 0,
        'when_made' => '2010_2015',
        //'recipient' => null,
        //'occasion' => null,
        //'style' => null
);
logical-and commented 9 years ago

Thank you, I will see it soon

ipsod commented 9 years ago

Cool, thank you!

logical-and commented 9 years ago

Soon :)

Tekrajs commented 6 years ago

Thanks. But I am stuck with the same problem. What i did is: After creating shipping template and listing, for uploading image: $url = "https://openapi.etsy.com/v2/listings/".$this->listing['listing_id']."/images"; $i = str_replace($wp_dir['url'],$wp_dir['path'],$image); $data = [ '@image' => '@'.$i.';type='.$img_type['type'] ]; this gave me image path as : Array ( [@image] => @E:\xampp\htdocs\wordpress/wp-content/uploads/2018/01/cd_4_angle.jpg;type=image/jpeg )

also $url = "https://openapi.etsy.com/v2/listings/".$this->listing['listing_id']."/images"; $i = str_replace($wp_dir['url'],$wp_dir['path'],$image); $data = [ 'image' => '@'.$i.';type='.$img_type['type'] ]; this gave me image path as : Array ( [image] => @E:\xampp\htdocs\wordpress/wp-content/uploads/2018/01/cd_4_angle.jpg;type=image/jpeg ) and this too: $url = "https://openapi.etsy.com/v2/listings/".$this->listing['listing_id']."/images"; $i = str_replace($wp_dir['url'],$wp_dir['path'],$image); $data = [ 'image' => '@'.$i.';type='.$img_type['type'] ]; this gave me image path as : Array ( [image] => @http://localhost/wordpress/wp-content/uploads/2013/06/cd_6_angle.jpg;type=image/jpeg) But in none of the case image is uploading. Products lists are uploaded, but why my image are not uploading ? .I already saw the link above for uploading image in etsy api site. Could you please help me through this?

ngr900 commented 3 years ago

Did anyone figure it out? I'm stuck on the same problem

hughgrigg commented 3 years ago

The example for this in Etsy's documentation.

This worked for me, though: https://notestoself.dev/posts/etsy-api-php-oauth-listing-image-upload/