gimucco/tiktok-loginkit
Composer 安装命令:
composer require gimucco/tiktok-loginkit
包简介
TikTok Login Kit for Web in PHP
README 文档
README
TikTok Login Kit implementation in PHP based on the official documentation.
This is an unofficial SDK for the official Login Kit APIs.
Features
The library has been updated to include video/image publish via Direct Post
Current features include:
- Log in with TikTok
- Retrieve Basic User Information
- Retrieve Advanced User Information
- Retrieve Videos
- Paginate Videos
- Refresh Expired Token
- NEW Publish a Video with "Direct Post" via URL
- NEW Publish a Video with "Direct Post" via File
- NEW Publish one or more Images with "Direct Post" via URLs
Installation
Install via Composer
composer require gimucco/tiktok-loginkit
Requirements
You need to have your app set up and approved in the TikTok Developer Portal.
If you're upgrading to the v2 TikTok API version, make sure you've added your Redirect URLs and selected the proper scopes.
Requirements for Direct Posts
If you're planning to publish videos/photos via Direct Post, you need to undergo an audit. More info here
Until you're approved:
- You can only publish private videos
- The account that you use for testing must also be private
Code Example for Logging in and retrieving basic info
// Initialize the class.
// $client_id and $client_secret are provided by TikTok.
// $redirect_uri must be approved in the TikTok developer portal.
$_TK = new TikTokLoginKit\Connector($client_id, $client_secret, $redirect_uri);
if (TikTokLoginKit\Connector::receivingResponse()) {
try {
$token = $_TK->verifyCode($_GET[TikTokLoginKit\Connector::CODE_PARAM]);
// Your logic to store the access token
$user = $_TK->getUser();
// Your logic to manage the User info
$videos = $_TK->getUserVideoPages();
// Your logic to manage the Video info
} catch (Exception $e) {
echo "Error: ".$e->getMessage();
echo '<br /><a href="?">Retry</a>';
}
} else {
echo '<a href="'.$_TK->getRedirect().'">Log in with TikTok</a>';
}
Alternative Constructor
If you prefer to use a .ini file to pass the api credentials, you can use the TikTokLoginKit\Connector::fromIni method.
The .ini file should have this simple structure
client_id = [your client id]
client_secret = [your client secret]
redirect_uri = [your redirect uri]
And you call the alternative constructor by passing the path to the .ini file
$_TK = TikTokLoginKit\Connector::fromIni(__DIR__.'/env.ini');
Examples
Refer to the examples folder for a quick examples of how to use the login, fetch and paginate videos, publish videos
gimucco/tiktok-loginkit 适用场景与选型建议
gimucco/tiktok-loginkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.56k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2021 年 05 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gimucco/tiktok-loginkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gimucco/tiktok-loginkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 32
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2021-05-30