【问题标题】:Creating new list on Etsy在 Etsy 上创建新列表
【发布时间】:2012-08-22 00:47:47
【问题描述】:

我正在尝试在 Etsy 上创建一个新列表。

  1. 我使用 oauth 进行身份验证并获得 OAUTH_CONSUMER_KEYOAUTH_CONSUMER_SECRET

  2. 我用这个代码检查它,我得到了所有卖家数据的回报,所以 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;
    }
    
  3. 我正在尝试创建一个新列表。首先,我设法通过生产环境中的 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/…
  • 你找到解决方案了吗?

标签: php api oauth etsy


【解决方案1】:

如果您仍在开发您的应用程序,您可以创建列表而无需获得完整的 API 访问权限,只要商店在您的帐户上。确保在发出第一个 OAUTH 请求时将 listings_w 解析为权限范围。我在下面的代码中更改了 ETSY 提供的示例。

    // instantiate the OAuth object
    // OAUTH_CONSUMER_KEY and OAUTH_CONSUMER_SECRET are constants holding your key and   secret
    // and are always used when instantiating the OAuth object 
    $oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);

    // make an API request for your temporary credentials
    $req_token = $oauth->getRequestToken("https://openapi.etsy.com/v2/oaut/request_token?scope=email_r%20listings_r%20listings_w", 'oob');

    print $req_token['login_url']."\n";`

注意scope=email_r%20listings_r%20listings_w;

希望对你有帮助

【讨论】:

    【解决方案2】:

    啊哈,here's the answer。来自 Etsy 开发人员:

    您的 API 尚未获得完全 API 访问权限的批准。我已经解决了这个问题,所以你现在应该可以使用这些方法了。

    因此,请与公司联系,并要求批准您的密钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-17
      • 1970-01-01
      相关资源
      最近更新 更多