msmm / mtmtz
There is no license information available for the latest version (v2.0.5) of this package.
美团 美天赚 基础封装
v2.0.5
2024-12-03 07:43 UTC
Requires
- php: ^7.1|^8.0
- ext-json: *
- guzzlehttp/guzzle: >=6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.0|^2.0|^3.0
- phpunit/phpunit: >=5.0
README
说明
提供了美团美天赚的接入鉴权封装及请求类的抽象
安装
composer require msmm/mtmtz
使用
<?php
declare(strict_types=1);
/**
* This file is part of msmm.
*/
namespace App\Helper\Sdk;
use Msmm\MtMtz\Client;
use Msmm\MtMtz\Requests\ApiQueryOrderRequest;
class ToolMtMTZ
{
/**
* 获取订单.
* @throws \Exception
*/
public function pullOrder(): array {
$client = new Client();
$client->setAppKey('xxxx');
$client->setSecret('xxxx');
$request = new ApiQueryOrderRequest();
$request->setStartTime(time() - 3600);
$request->setEndTime(time());
$request->setPage(1);
$request->setLimit(20);
$request->setQueryTimeType(1);
$request->setBusinessLine([7]);
return $client->execute($request);
}
}
扩展
本库只实现了美团美天赚的自用接口,如果需要扩展,请参考以下步骤
- 添加新的接口请求类,继承
Msmm\MtMtz\Requests\AbstractRequest
抽象类 - 实现
getApiMethodName
getApiParams
方法,如果返回值有要求重写Msmm\MtMtz\Requests\AbstractRequest
抽象类的getResult
方法即可 - 具体实现请参考
Msmm\MtMtz\Requests\ApiQueryOrderRequest
类