我正尝试在Etsy上创建新列表。在Etsy上创建新列表
我使用OAuth的认证,并获得
OAUTH_CONSUMER_KEY
和OAUTH_CONSUMER_SECRET
我与此代码检查,我得到了回报OG所有卖家的数据,所以一切正常使用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.
嗯,做 “Etsy的限制API密钥” 网络搜索。我想知道你是否对这项服务提出了太多要求,而你的钥匙已经被放进了一个罪犯箱?查看他们的FAQ或支持页面。 – halfer
不,我没有做出很多请求。当我创建一个请求http://openapi.etsy.com/v2/users/__SELF__“它正在工作。 – Yan
嗨,你是如何得到这个?运气? – halfer