|
...
|
...
|
@@ -7,6 +7,7 @@ use Lackoxygen\TiktokOpen\Base\Event\Fail; |
|
|
|
use Lackoxygen\TiktokOpen\Base\Event\Request;
|
|
|
|
use Lackoxygen\TiktokOpen\Base\Event\Response;
|
|
|
|
use Lackoxygen\TiktokOpen\Base\ServiceManager;
|
|
|
|
use Lackoxygen\TiktokOpen\Base\Signer\SignerInterface;
|
|
|
|
use Lackoxygen\TiktokOpen\Base\Traits\BaseClient;
|
|
|
|
use Lackoxygen\TiktokOpen\Wap\Listener;
|
|
|
|
use GuzzleHttp\RequestOptions;
|
|
...
|
...
|
@@ -20,10 +21,13 @@ class Client extends ServiceManager |
|
|
|
|
|
|
|
private bool $withSession;
|
|
|
|
|
|
|
|
private SignerInterface $signer;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
Application $app, $requestOption = '', $withSession = false
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Application $app,
|
|
|
|
$requestOption = '',
|
|
|
|
$withSession = false
|
|
|
|
) {
|
|
|
|
parent::__construct($app);
|
|
|
|
|
|
|
|
$this->listen();
|
|
...
|
...
|
@@ -43,38 +47,29 @@ class Client extends ServiceManager |
|
|
|
|
|
|
|
public function asForm(): Client
|
|
|
|
{
|
|
|
|
return new Client(
|
|
|
|
$this->app,
|
|
|
|
RequestOptions::FORM_PARAMS,
|
|
|
|
$this->withSession
|
|
|
|
);
|
|
|
|
return new Client($this->app, RequestOptions::FORM_PARAMS, $this->withSession);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asJson(): Client
|
|
|
|
{
|
|
|
|
return new Client(
|
|
|
|
$this->app,
|
|
|
|
RequestOptions::JSON,
|
|
|
|
$this->withSession
|
|
|
|
);
|
|
|
|
return new Client($this->app, RequestOptions::JSON, $this->withSession);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asMultipart(): Client
|
|
|
|
{
|
|
|
|
return new Client(
|
|
|
|
$this->app,
|
|
|
|
RequestOptions::MULTIPART,
|
|
|
|
$this->withSession
|
|
|
|
);
|
|
|
|
return new Client($this->app, RequestOptions::MULTIPART, $this->withSession);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withSession(): Client
|
|
|
|
{
|
|
|
|
return new Client(
|
|
|
|
$this->app,
|
|
|
|
$this->requestOption,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
return new Client($this->app, $this->requestOption, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function signVia(SignerInterface $signer): Client
|
|
|
|
{
|
|
|
|
$this->signer = $signer;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function refresh()
|
...
|
...
|
|