stallzhan / tiktok-php-sdk-unofficial
根据tiktok文档实现的PHP登录工具包
1.0.0.0
2022-12-15 02:37 UTC
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ~6.0||~7.0
This package is auto-updated.
Last update: 2024-09-15 07:05:38 UTC
README
根据tiktok文档实现的PHP登录工具包
- 参考文档
- https://developers.tiktok.com/doc/login-kit-overview/
- 登录工具包
- 这是一个官方登录工具包API的非官方SDK。
- 特性
- 当前特性包括
- 生成TikTok授权
- 获取tiktok V2用户信息
- 获取访问令牌
- 刷新过期令牌
- 目前正在改进中
- 视频工具包
安装
composer require stallzhan/tiktok-php-sdk-unofficial
基本示例
// include your composer dependencies require_once 'vendor/autoload.php'; try { $client = new \Tiktok\Client(); $client->setClientKey("xxx"); $client->setClientSecret("xxx"); $client->setScopes([ "user.info.basic", "video.upload" ]); $client->setState("xxx"); $client->setRedirectUri("xxx"); $authUrl = $client->createAuthUrl(); header("Location: $authUrl"); if ($_GET['code']) { $data = $client->fetchAccessTokenWithAuthCode($_GET['code']); $client->setCredentials($data); } } catch (Exception $e) { var_dump($e->getMessage()); }
APIs
安装
设置凭据
$client->setCredentials($data);
获取tiktok V2用户信息
$server = new \Tiktok\Service($client); $userinfo = $server->userinfo_v2->get();
刷新过期令牌
$data = $client->refreshToken();