added 新增获取二维码接口

This commit is contained in:
zhaoxiang 2021-11-16 16:56:11 +08:00
parent acce7df405
commit d46b07c64c
4 changed files with 64 additions and 9 deletions

View File

@ -147,12 +147,9 @@ class BaseClient {
if (empty($this->middlewares)) {
$this->registerHttpMiddlewares();
}
$response = $this->performRequest($url, $method, $options);
$this->app->events->dispatch(new Events\HttpResponseCreated($response));
return $returnRaw ? $response : $this->castResponseToType($response, $this->app->config->get('response_type'));
return $this->castResponseToType($response, $this->app->config->get('response_type'));
}
/**

View File

@ -4,13 +4,12 @@ namespace EasyTiktok\MiniProgram;
use EasyTiktok\Kernel\ServiceContainer;
use EasyTiktok\Kernel\Traits\ResponseCastable;
use EasyTiktok\MiniProgram\Auth\AccessToken;
use EasyTiktok\MiniProgram\Base\Client;
/**
* Class Application.
* @property Client $base
* @property AccessToken $access_token
* @property Base\Client $base
* @property Auth\AccessToken $access_token
* @property QrCode\Client $qr_code
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
class Application extends ServiceContainer {
@ -22,7 +21,8 @@ class Application extends ServiceContainer {
*/
protected $providers = [
Base\ServiceProvider::class,
Auth\ServiceProvider::class
Auth\ServiceProvider::class,
QrCode\ServiceProvider::class
];
/**

View File

@ -0,0 +1,32 @@
<?php
/**
* This file is part of the apiadmin/tiktok.
*/
namespace EasyTiktok\MiniProgram\QrCode;
use EasyTiktok\Kernel\BaseClient;
use EasyTiktok\Kernel\Exceptions\HttpException;
use EasyTiktok\Kernel\Exceptions\InvalidConfigException;
use GuzzleHttp\Exception\GuzzleException;
/**
*
*/
class Client extends BaseClient {
/**
* 创建抖音二维码
*
* @return array
*
* @throws InvalidConfigException
* @throws GuzzleException|HttpException
*/
public function createQr(): array {
return $this->httpPostJson('apps/qrcode', [
'appname' => 'douyin',
'set_icon' => true
]);
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* This file is part of the apiadmin/tiktok.
*/
namespace EasyTiktok\MiniProgram\QrCode;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
/**
* QrCode ServiceProvider.
*
* @author dysodeng <dysodengs@gmail.com>
*/
class ServiceProvider implements ServiceProviderInterface {
/**
* {@inheritdoc}.
*/
public function register(Container $pimple): void {
$pimple['qr_code'] = static function($app) {
return new Client($app);
};
}
}