encoderuz/uzpost-php 问题修复 & 功能扩展

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

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

encoderuz/uzpost-php

Composer 安装命令:

composer require encoderuz/uzpost-php

包简介

Uzpost integration package for php

README 文档

README

UzpostClient is a PHP client for interacting with the Uzpost API. It simplifies sending HTTP requests, managing authentication, and handling API responses.

Installation

composer require encoderuz/uzpost-php

Usage

For using UzpostClient api requests you need token. For getting token you don't need api_key. You just use this case:

 $token = UzpostClient::token("your_username", "your_password");
 $client = new UzpostClient($token);

Methods

token(string $username, string $password): string

Authenticates a user and retrieves an authentication token.

$username (string): User's login username.

$password (string): User's password.

Returns (string): JWT authentication token.

Example:

$token = UzpostClient::token('your-username', 'your-password');
get_result(): array
  • Returns the result of the last API request.
  • Returns (array): API response data.
send_request(string $method, string $endpoint, array $params = [], string $api_version = 'v1'): UzpostClient
  • Sends an HTTP request to the Uzpost API.

  • $method (string): HTTP method (GET, POST, etc.).

  • $endpoint (string): API endpoint.

  • $params (array): Request parameters.

  • $api_version (string): API version. Default is v1.

  • Returns (UzpostClient): The current instance with the response stored in result.

Example:

$response = $client->send_request('GET', 'tracking/123456');
$result = $client->get_result();

Services

2. CustomerService

Handles authentication and customer-related operations.

Usage:

$customerService = new CustomerService($client);

Read more about CustomerService

3. JurisdictionService

Retrieves jurisdiction-related data.

Usage:

$jurisdictionService = new JurisdictionService($client);

Read more about JurisdictionService

4. OrderService

Handles order tracking, retrieval, creation, and cancellation.

Usage:

$orderService = new OrderService($client);

Read more about OrderService

5. PricingService

Fetches package pricing and service types.

Usage:

$pricingService = new PricingService($client);

Read more about PricingService

Exception Handling

All methods in these services throw UzpostException in case of API request failure.

Example:

try {
    $orders = $orderService->get_customer_orders(1, 10);
} catch (UzpostException $e) {
    echo "Error: " . $e->getMessage();
}

License

This package is open-source and available under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

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