Accept: */*Accept-Language: enContent-length: 20878Authorization: OAuth oauth_consumer_key="[key]",oauth_signature_method="HMAC-SHA1",oauth_nonce="qwb1dgvco0bd35rop2q2kb3qalmfg9cj",oauth_timestamp="1408306744",oauth_version="1.0",oauth_token="[token]",oauth_signature="%2qGLDILhWmrwKpZG7YwkeX49TXoY%3D"Connection: Keep-AlivePragma: no-cacheHost: openapi.etsy.comContent-Type: multipart/form-data; boundary=fc684a0c-ac89-4771-9ca0-61d0a4326b65--fc684a0c-ac89-4771-9ca0-61d0a4326b65Content-Disposition: form-data; name="userfile"Poly1.jpg--fc684a0c-ac89-4771-9ca0-61d0a4326b65Content-Disposition: form-data; name="image"; filename="Poly1.jpg"Content-Type: image/jpegContent-Length: 20544Content-Transfer-Encoding: binary
[raw data]--fc684a0c-ac89-4771-9ca0-61d0a4326b65--HTTP/1.1 400 Bad RequestDate: Sun, 17 Aug 2014 20:19:13 GMTServer: ApacheX-Etsy-Request-Uuid: MR8IvCBibWa0biiuB1YXSxh8bdRrX-RateLimit-Limit: 10000X-RateLimit-Remaining: 9984X-Error-Detail: Image file or image_id string must be includedCache-Control: privateX-Cnection: closeContent-Type: text/plain;charset=UTF-8Content-Length: 46Accept-Ranges: bytesVia: 1.1 varnishX-Served-By: cache-sjc3126-SJCX-Cache: MISSX-Cache-Hits: 0X-Timer: S1408306753.529277086,VS0,VE208Vary: Accept-EncodingSet-Cookie: uaid=uaid%3Db1ylwJtYwVIOjnlvd1oYF3zHivLt%26_now%3D1408306753%26_slt%3DBqs0S_Ia%26_kid%3D1%26_ver%3D1%26_mac%3DLi85jnz6IXyrP0Awm6bir6bUNTUPEST6gaLoU4eztoI.; expires=Tue, 16-Aug-2016 20:19:13 GMT; path=/; domain=.etsy.com; httponlyConnection: close<?php
$consumer_key = '[masked]';$consumer_secret = '[masked]';$access_token = '[masked]';$access_token_secret = '[masked]';
$oauth = new OAuth( $consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setNonce ( 'random' );$oauth->enableDebug();$oauth->setRequestEngine( OAUTH_REQENGINE_CURL );$oauth->setToken($access_token, $access_token_secret);
$source_file = dirname(realpath(__FILE__)) ."/Poly1.jpg";
if ( file_exists( $source_file ) ) {
try { $parameterss = array('@image' => '@'.$source_file.';type=image/jpeg'); $data = $oauth->fetch( $url, $parameters, OAUTH_HTTP_METHOD_POST); $json = $oauth->getLastResponse(); print_r(json_decode($json, true)); } catch (OAuthException $e) { print_r($oauth->debugInfo); exit; } } else { echo 'image not found'; }
?>Array( [sbs] => POST&https%3A%2F%2Fopenapi.etsy.com%2Fv2%2Flistings%2F200094932%2Fimages&oauth_consumer_key%3D[masked]%26oauth_nonce%3Drandom%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1408374616%26oauth_token%3D[masked]%26oauth_version%3D1.0 [headers_sent] => POST /v2/listings/200094932/images?oauth_consumer_key=[masked]&oauth_signature_method=HMAC-SHA1&oauth_nonce=random&oauth_timestamp=1408374616&oauth_version=1.0&oauth_token=[masked]&oauth_signature=M0FBGvMgNOuhb1r3Ln9NaQIIFSM%3D HTTP/1.1User-Agent: PECL-OAuth/1.2.3Host: openapi.etsy.comAccept: */* [headers_recv] => HTTP/1.1 400 Bad RequestDate: Mon, 18 Aug 2014 15:10:07 GMTServer: ApacheX-Etsy-Request-Uuid: F2Y9eBN91GSEB7EIPzCKLAHHkyyiX-RateLimit-Limit: 10000X-RateLimit-Remaining: 9994X-Error-Detail: Image file or image_id string must be includedCache-Control: privateX-Cnection: closeContent-Type: text/plain;charset=UTF-8Content-Length: 46Accept-Ranges: bytesVia: 1.1 varnishX-Served-By: cache-dfw1829-DFWX-Cache: MISSX-Cache-Hits: 0X-Timer: S1408374607.161081314,VS0,VE206Vary: Accept-EncodingSet-Cookie: uaid=uaid%3DA7gICSophLGrhclExqJAiz-AQzJj%26_now%3D1408374607%26_slt%3DHkL30WQH%26_kid%3D1%26_ver%3D1%26_mac%3DYxX5sA_Ji6melhnPha0ZPlEpQAOraibX85ziR3EgU1U.; expires=Wed, 17-Aug-2016 15:10:07 GMT; path=/; domain=.etsy.com; httponlyConnection: close [body_recv] => Image file or image_id string must be included [info] => About to connect() to openapi.etsy.com port 443 (#0) Trying 23.235.44.185... connectedsuccessfully set certificate verify locations: CAfile: none CApath: /etc/ssl/certsSSLv3, TLS handshake, Client hello (1):SSLv3, TLS handshake, Server hello (2):SSLv3, TLS handshake, CERT (11):SSLv3, TLS handshake, Server key exchange (12):SSLv3, TLS handshake, Server finished (14):SSLv3, TLS handshake, Client key exchange (16):SSLv3, TLS change cipher, Client hello (1):SSLv3, TLS handshake, Finished (20):SSLv3, TLS change cipher, Client hello (1):SSLv3, TLS handshake, Finished (20):SSL connection using ECDHE-RSA-RC4-SHAServer certificate: subject: C=US; ST=California; L=San Francisco; O=Fastly, Inc.; CN=*.a.ssl.fastly.net start date: 2014-01-01 00:00:00 GMT expire date: 2015-01-05 12:00:00 GMT subjectAltName: openapi.etsy.com matched issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3 SSL certificate verify ok.Closing connection #0SSLv3, TLS alert, Client hello (1):)--
You received this message because you are subscribed to the Google Groups "Etsy API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etsy-api-v2...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken($access_token, $access_token_secret);
$url = "https://openapi.etsy.com/v2/listings/277895742/images";
$data = array('image' =>'@folder/pixel.jpg'); // also tried to provide full path from /wwwroot
$headers = array("Content-Type" => "multipart/form-data"); // also tried to add Content-Length
$oauth->fetch($url, $data, OAUTH_HTTP_METHOD_POST, $headers);
Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect) with message in debug info: "the request body is too large". sudo pecl install oauth-1.2.3
edit php.ini:
sudo nano /etc/php5/apache2/php.ini
add next line:
extension=oauth.so NOT at final of php.ini
restart service:
sudo /etc/init.d/apache2 restart
The code
{ //initialize oauth $oauth2 = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth2->setRequestEngine( OAUTH_REQENGINE_CURL ); $oauth2->setVersion("1.1"); //very important $oauth2->enableDebug(); $oauth2->setToken($access_token, $access_token_secret); //params $listing_id = '4564613216'; //id of a listing/product $url = "https://openapi.etsy.com/v2/listings/".$listing_id."/images"; $filename = "image.jpg"; $source_file = dirname(realpath(__FILE__)) ."/images/$filename"; $mimetype = mime_content_type($source_file); $filesize = filesize($source_file); $params = array('@image' => '@'.$source_file.';type='.$mimetype); //buid some header params $header["Content-Type"] = 'multipart/form-data'; $header["Content-Length"] = $filesize; $header["Content-Disposition"] = 'form-data; name="image"; filename="image.jpg"'; $header["Content-Transfer-Encoding"] = 'binary'; //execute $data = $oauth2->fetch($url, $params, OAUTH_HTTP_METHOD_POST, $header); $json = $oauth2->getLastResponse(); print_r(json_decode($json, true));} catch (OAuthException $e) { // You may want to recover gracefully here... print $oauth2->getLastResponse()."\n"; print_r($oauth2->debugInfo); die($e->getMessage());}Enter code here...<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\nAn error occurred while processing your request.<p>\nReference #95.5a87d317.1509978985.162f55f0\n</BODY></HTML>\nEnter code here...var oauth = {