2015-08-29 16 views
0

我試圖將圖像添加到現有的Etsy列表中。應該簡單嗎?但是我在這裏按照API代碼: https://www.etsy.com/developers/documentation/reference/listingimageEtsy圖像添加返回500錯誤 - 元數據看起來不像_FILES數組

和我得到一個內部服務器的500錯誤響應: 「」圖像陣列元數據看起來並不像一個_FILES數組「」

我沒有了解這個錯誤的含義。任何人?

這裏是我的代碼:

<?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()); 
} 
?> 

回答

0

解決。

添加的代碼: $ oauth-> setRequestEngine(OAUTH_REQENGINE_CURL);

如果上述失敗並出現錯誤 - 重新安裝PHP PECL擴展並添加Curl作爲「請求引擎」。

相關問題