【发布时间】:2012-08-22 00:47:47
【问题描述】:
我正在尝试在 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.
【问题讨论】:
-
嗯,在“Etsy 受限 API 密钥”上进行网络搜索。不知道是不是你对服务的请求太多了,你的key被放到了sin-bin了?查看他们的常见问题解答或支持页面。
-
不,我没有提出很多要求。当我向openapi.etsy.com/v2/users/__SELF__创建请求时,它正在工作。
-
嗨,你是怎么做到的?运气好吗?
-
是的,我联系他们以获得完全访问权限。欲了解更多信息,请访问谷歌群组groups.google.com/forum/?fromgroups=#!topic/etsy-api-v2/…
-
你找到解决方案了吗?