Etsy Image add returning 500 error - metadata doesn't look like a _FILES array

↘锁芯ラ 提交于 2019-12-25 05:48:46

问题


I am trying to add an images to an existing Etsy listing. Should be simple right? But I'm following the API code here: https://www.etsy.com/developers/documentation/reference/listingimage

And am getting an internal server 500 error response: ""The image array metadata doesn't look like a _FILES array""

I have no idea what this error means. Anyone?

Here is my code:

<?php
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);

$oauth->enableDebug();
$oauth->setToken($access_token, $access_token_secret);
$listing_id = 245891757
$filename = 161784082898-0.JPG;
$mimetype="image/jpeg";


try {
    $source_file = dirname(realpath(__FILE__)) ."/$filename";
    $url = "https://openapi.etsy.com/v2/listings/".$listing_id."/images";
    $params = array('image' => '@'.$source_file.';type='.$mimetype);

    $oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);

    $json = $oauth->getLastResponse();
    print_r(json_decode($json, true));

} catch (OAuthException $e) {
    // You may want to recover gracefully here...
    print "<br><br>".$oauth->getLastResponse()."\n";
    print_r($oauth->debugInfo);
    die($e->getMessage());
}
?>

回答1:


Solved.

code added: $oauth->setRequestEngine( OAUTH_REQENGINE_CURL );

If the above fails with an error - re-install the PHP PECL extension and add Curl as a "Request Engine".



来源:https://stackoverflow.com/questions/32282899/etsy-image-add-returning-500-error-metadata-doesnt-look-like-a-files-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!