Etsyで新しいリストを作成しようとしています。
私はoauthを使用して認証し、取得
OAUTH_CONSUMER_KEY
し ましたOAUTH_CONSUMER_SECRET
このコードで確認すると、すべての販売者データが返されるので、OAuthですべて問題ありません。
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth->setToken("key","secret"); try { $data = $oauth->fetch("http://openapi.etsy.com/v2/users/__SELF__", null, OAUTH_HTTP_METHOD_GET); $json = $oauth->getLastResponse(); print_r(json_decode($json, true)); } catch (OAuthException $e) { error_log($e->getMessage()); error_log(print_r($oauth->getLastResponse(), true)); error_log(print_r($oauth->getLastResponseInfo(), true)); exit; }
新しいリストを作成しようとしています。最初に、本番環境のAPIブラウザーを使用して新しいリストを作成することができました。今、私はPHPを介して新しいリストを作成したいと思います。これは私がしたことであり、それは私のエラーを返します:
これは私のコードです:
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET,OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setToken("key","secret");
try {
$url = "http://openapi.etsy.com/v2/listings";
$params = array('description' => 'thisisdesc','materials' => 'yes','price'=>"5.99"
,'quantity'=>"2",'shipping_template_id'=>"52299",'shop_section_id'=>"1"
,'title'=>"thisistitle",'category_id'=>"i_did",'who_made'=>"5.99"
,'is_supply'=>"1",'when_made'=>"2010_2012");
$oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
print_r(json_decode($json, true));
} catch (OAuthException $e) {
print_r($e);
error_log($e->getMessage());
error_log(print_r($oauth->getLastResponse(), true));
error_log(print_r($oauth->getLastResponseInfo(), true));
exit;
}
私は次の応答を受け取ります:
Invalid auth/bad request (got a 403, expected HTTP/1.1 20X or a redirect)
This method not accessible to restricted API key.