首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在Amazon API Orders API中遇到了一个错误:“应用程序不能访问部分或全部请求的资源”。

我在Amazon API Orders API中遇到了一个错误:“应用程序不能访问部分或全部请求的资源”。
EN

Stack Overflow用户
提问于 2022-07-29 08:36:04
回答 1查看 405关注 0票数 1

在从Orders API调用方法getOrders()/getOrder()时,我得到了一个错误:“应用程序无法访问部分或所有请求的资源”。

我把代码完全取自https://github.com/jlevers/selling-partner-api。我安装了composer require jlevers/selling-partner-api并按照指令连接到销售伙伴API。

此外,我还尝试调用$result = $apiInstance>getMarketplaceParticipations(),它没有任何特定的错误,所以我不认为这是配置中的错误。

有人能为我指出正确的方向来解决这个问题吗?

代码

代码语言:javascript
复制
<?php
require_once(__DIR__ . '/vendor/autoload.php');
    
$token = "<TOKEN>";
    
    use SellingPartnerApi\Api\SellersV1Api as SellersApi;
    use SellingPartnerApi\Configuration;
    use SellingPartnerApi\Endpoint;
    
    $config = new Configuration([
        "lwaClientId" => "amzn1.applica..",
        "lwaClientSecret" => "<clientSecret>",
        "lwaRefreshToken" => $token,
        "awsAccessKeyId" => "<accessKey>",
        "awsSecretAccessKey" => "<secretAcessKey>",
        "endpoint" => Endpoint::FE
    ]);
    
    $apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config);
    $marketplace_ids = array('A1############'); 
    $created_after = '2022-07-27';
    
    try {
        $result = $apiInstance->getOrders($marketplace_ids);

        print "<pre>";
        print_r($result);
        print "</pre>";
    
    } catch (Exception $e) {
    
        echo 'Exception when calling OrdersV0Api->getOrders: ', $e->getMessage(), PHP_EOL;
    }

错误消息

代码语言:javascript
复制
Exception when calling OrdersV0Api->getOrders: [400] { "errors": [ { "code": "InvalidInput", "message": "Application do not have access to some or all requested resource", "details": "" } ] }
EN

回答 1

Stack Overflow用户

发布于 2022-08-05 05:55:45

之后以这种格式创建:

代码语言:javascript
复制
$created_after = new \DateTime("2021-10-01");
$after_str = $created_after->format('Y-m-d\TH:i:s\Z');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73163832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档