limingxinleo / douyin-openapi
v0.2.2
2024-07-17 02:50 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.8
- hyperf/codec: ^3.1
- hyperf/collection: ^3.1
- hyperf/support: ^3.1
- jetbrains/phpstorm-attributes: ^1.0
- pimple/pimple: ^3.5
- psr/simple-cache: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/redis: ^3.1
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- swoole/ide-helper: dev-master
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2024-10-17 03:34:38 UTC
README
composer require limingxinleo/douyin-openapi
如何使用
<?php use Fan\DouYin\OpenApi\Application; use Psr\Container\ContainerInterface; $config = [ 'app_id' => $app->app_id, 'app_secret' => $app->secret, 'payment' => [ 'salt' => $app->salt, 'token' => $app->token, ], ]; // 协程安全,可以常驻到容器中 $dy = new Application($config); // 创建预定单 $client = $dy->http->client(options: [ 'base_uri' => 'https://developer.toutiao.com', 'timeout' => 5, ]); $json = [ 'out_order_no' => 'xxx', 'total_amount' => 'xxx', 'subject' => 'xxx', 'body' => 'xxx', 'valid_time' => 'xxx', 'cp_extra' => 'xxx', 'thirdparty_id' => 'xxx', 'notify_url' => 'xxx', 'limit_pay_way' => 'xxx', 'nonce' => 'xxx', // 无任何业务影响, 仅影响加签内容, 使同一请求的多次签名不同 ]; $json['sign'] = $dy->payment->sign($json); $json['app_id'] = $dy->config->getAppId(); $res = $client->post('/api/apps/ecpay/v1/create_order', [ 'json' => $json, ]); $res = Json::decode($content)['data'] ?? []; var_dump($res);