zero-to-prod/spapi-lwa-cli 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zero-to-prod/spapi-lwa-cli

最新稳定版本:v2.1.0

Composer 安装命令:

composer require zero-to-prod/spapi-lwa-cli

包简介

A CLI for connecting to Amazons Selling Partner API with Login With Amazon (LWA).

README 文档

README

Repo GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Actions Workflow Status Packagist Downloads php Packagist Version License wakatime Hits-of-Code

Contents

Introduction

A CLI for connecting to Amazons Selling Partner API with Login With Amazon (LWA).

Requirements

  • PHP 8.1 or higher.

Installation

Install Zerotoprod\SpapiLwaCli via Composer:

composer require zero-to-prod/spapi-lwa-cli

This will add the package to your project's dependencies and create an autoloader entry for it.

Documentation Publishing

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

# Publish to default location (./docs/zero-to-prod/spapi-lwa-cli)
vendor/bin/zero-to-prod-spapi-lwa-cli

# Publish to custom directory
vendor/bin/zero-to-prod-spapi-lwa-cli /path/to/your/docs

Automatic Documentation Publishing

You can automatically publish documentation by adding the following to your composer.json:

{
    "scripts": {
        "post-install-cmd": [
            "zero-to-prod-spapi-lwa-cli"
        ],
        "post-update-cmd": [
            "zero-to-prod-spapi-lwa-cli"
        ]
    }
}

Usage

Run this command to see the available commands:

vendor/bin/spapi-lwa-cli list

Available Commands

spapi-lwa-cli:refresh-token

Description: Login With Amazon with a refresh_token.

Usage:

vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token [options] <refresh_token> <client_id> <client_secret>

Arguments:

  • refresh_token (required): The LWA refresh token
  • client_id (required): Get this value when you register your application
  • client_secret (required): Get this value when you register your application

Options:

  • --user_agent[=USER_AGENT]: User Agent
  • --response: Returns the full response
  • --refresh_token: Returns the refresh_token
  • --token_type: Returns the token_type
  • --expires_in: Returns expires_in

Examples:

# Get access token (default behavior)
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret"

# Get the full response
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --response

# Get only the token type
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --token_type

# With custom user agent
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --user_agent="MyApp/1.0"

Sample Output (access token):

Atzr|IwEBIAxHQiJEuOjl-123456789abcdef...

Sample Output (full response with --response):

{
    "response": {
        "access_token": "Atzr|IwEBIAxHQiJEuOjl-123456789abcdef...",
        "token_type": "bearer",
        "expires_in": 3600,
        "refresh_token": "Atzr|IwEBIA..."
    },
    "info": {
        "url": "https://api.amazon.com/auth/o2/token",
        "content_type": "application/json; charset=utf-8",
        "http_code": 200,
        "total_time": 0.234567
    }
}

spapi-lwa-cli:client-credentials

Description: Login With Amazon with client credentials.

Usage:

vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials [options] <scope> <client_id> <client_secret>

Arguments:

  • scope (required): The scope of the LWA authorization grant
  • client_id (required): Get this value when you register your application
  • client_secret (required): Get this value when you register your application

Options:

  • --user_agent[=USER_AGENT]: User Agent
  • --response: Returns the full response
  • --scope: Returns the scope
  • --token_type: Returns the token_type
  • --expires_in: Returns expires_in

Examples:

# Get access token (default behavior)
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret"

# Get the full response
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --response

# Get only the scope
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --scope

# With custom user agent
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --user_agent="MyApp/1.0"

Sample Output (access token):

Atza|IwEBIAxHQiJEuOjl-987654321fedcba...

Sample Output (full response with --response):

{
    "response": {
        "access_token": "Atza|IwEBIAxHQiJEuOjl-987654321fedcba...",
        "scope": "sellingpartnerapi::notifications",
        "token_type": "bearer",
        "expires_in": 3600
    },
    "info": {
        "url": "https://api.amazon.com/auth/o2/token",
        "content_type": "application/json; charset=utf-8",
        "http_code": 200,
        "total_time": 0.567890
    }
}

spapi-lwa-cli:src

Description: Project source link

Usage:

vendor/bin/spapi-lwa-cli spapi-lwa-cli:src

Arguments: None

Options: None

Example:

vendor/bin/spapi-lwa-cli spapi-lwa-cli:src

Sample Output:

https://github.com/zero-to-prod/spapi-lwa-cli

Docker Image

You can also run the cli using the docker image:

docker run --rm davidsmith3/spapi-lwa-cli

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.

统计信息

  • 总下载量: 227
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固