debuss-a/lapostesuivi 问题修复 & 功能扩展

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

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

debuss-a/lapostesuivi

Composer 安装命令:

composer require debuss-a/lapostesuivi

包简介

This API allows you to track your La Poste shipments in real time.

README 文档

README

Logo

La Poste Suivi API

The best way to track your La Poste, Colissimo and Chronopost packages.

Travis Version License


Example


What does it do ?

This framework-agnostic package is an implementation of the tracking API version 2 from La Poste.
This API allows you to track your shipments in real time. "Suivi v2" allows you to harmonize the delivery status of tracked parcels, Colissimo parcels and Chronopost shipments.

More information on the developer page.

Installation

It is recommended to use composer to install the package :

$ composer require debuss-a/lapostesuivi:^2 

PHP 5.6 or newer is required.

Usage

First of all you need an X-Okapi-Key to use the API.
Subscribe to a new Tracking API to get one (it is free), here, then you can instantiate the app :

require_once __DIR__.'/vendor/autoload.php';

$app = new LaPoste\Suivi\App('YOUR_X-OKAPI-KEY_HERE');

You need to create an object Request for every tracking number :

$request = new \LaPoste\Suivi\Request('6M17554710224');

You can pass 2 more parameters to define the lang and ip_address you wish to set up. By default, lang is set to fr_FR and ip_address to $_SERVER['REMOTE_ADDR'] (or 123.123.123.123 if REMOTE_ADDR is not defined).

To track only 1 parcel, you can use the LaPoste\Suivi\App::call method :

require_once __DIR__.'/vendor/autoload.php';

$app = new LaPoste\Suivi\App('YOUR_X-OKAPI-KEY_HERE');
$request = new \LaPoste\Suivi\Request('6M17554710224');
$response = $app->call($request);

To track more than 1 parcel, use the LaPoste\Suivi\App::callMultiple method :

require_once __DIR__.'/vendor/autoload.php';

$app = new LaPoste\Suivi\App('YOUR_X-OKAPI-KEY_HERE');
$requests = [
    new \LaPoste\Suivi\Request('6M17554710224'),
    new \LaPoste\Suivi\Request('EY604176344FR', LaPoste\Suivi\App::LANG_EN),
    new \LaPoste\Suivi\Request('6M17554710224'),
];
$responses = $app->callMultiple($requests);

LaPoste\Suivi\App::call and LaPoste\Suivi\App::callMultiple return instances of LaPoste\Suivi\Response.

Note: in the case of LaPoste\Suivi\App::callMultiple, this package uses curl_multi* functions therefore all tracking numbers are tracked asynchronously.
This means the tracking of multiple packages is done at the same time instead of one by one, and it is much MUCH! faster.

Decorator

The package is included with an AppV1Decorator decorator class that you can use to format the output of the v2 API to the v1 API.

$app = new \LaPoste\Suivi\AppV1Decorator(
    new LaPoste\Suivi\App('YOUR_X-OKAPI-KEY_HERE')
);

$single_response = $app->call(new \LaPoste\Suivi\Request('6A18987970674'));

$multiple_response = $app->callMultiple([
    new \LaPoste\Suivi\Request('6A18987970674'),
    new \LaPoste\Suivi\Request('6A18987970674'),
    new \LaPoste\Suivi\Request('6A18987970674')
]);

Result of call :

array (
  'code' => '6A18987970674',
  'date' => '06/07/2020',
  'status' => 'LIVRE',
  'message' => 'Votre colis est livré à votre gardien.',
  'link' => 'https://www.laposte.fr/particulier/outils/suivre-vos-envois?code=6A18987970674',
  'type' => 'Colissimo',
)

Result of callMultiple :

array (
  0 => array (
    'data' => array (
      'code' => '6A18987970674',
      'date' => '06/07/2020',
      'status' => 'LIVRE',
      'message' => 'Votre colis est livré à votre gardien.',
      'link' => 'https://www.laposte.fr/particulier/outils/suivre-vos-envois?code=6A18987970674',
      'type' => 'Colissimo',
    ),
  ),
  1 => array (
    'data' => array (
      'code' => '6A18987970674',
      'date' => '06/07/2020',
      'status' => 'LIVRE',
      'message' => 'Votre colis est livré à votre gardien.',
      'link' => 'https://www.laposte.fr/particulier/outils/suivre-vos-envois?code=6A18987970674',
      'type' => 'Colissimo',
    ),
  ),
  2 => array (
    'data' => array (
      'code' => '6A18987970674',
      'date' => '06/07/2020',
      'status' => 'LIVRE',
      'message' => 'Votre colis est livré à votre gardien.',
      'link' => 'https://www.laposte.fr/particulier/outils/suivre-vos-envois?code=6A18987970674',
      'type' => 'Colissimo',
    ),
  ),
)

Useful if you do not want to refactor all your code to the different v2 API !

License

The package is licensed under the MIT license. See License File for more information.

debuss-a/lapostesuivi 适用场景与选型建议

debuss-a/lapostesuivi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.87k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「tracking」 「colissimo」 「laposte」 「poste」 「suivi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 debuss-a/lapostesuivi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 debuss-a/lapostesuivi 我们能提供哪些服务?
定制开发 / 二次开发

基于 debuss-a/lapostesuivi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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