komptip/php-tiktok-sdk

PHP sdk for TikTok

v1.1.0 2025-05-27 12:58 UTC

This package is auto-updated.

Last update: 2025-07-08 20:24:35 UTC


README

This package provides an wrapper for TikTok REST API for PHP 8.3 and later

Requirements

  • PHP >= 8.3

Installation

In your exist PHP application you can install this package using Composer.

composer require komptip/php-tiktok-sdk

Usage

Check documentation for basic understanding of configuration and usage, and user authentication for user authentication

Here is a basic example of how to use this package:

use Komptip\PhpTiktokSdk\PhpTiktokSdk;
use Komptip\PhpTiktokSdk\AuthorizationScope;
use Komptip\PhpTiktokSdk\UserField;

$tiktok = new PhpTiktokSdk('client_key', 'client_secret');

// Get auth url
$authUrl = $tiktok->createAuthUrl(
    scopes: [AuthorizationScope::UserInfoBasic, AuthorizationScope::UserInfoProfile],
    csrfState: $tiktok->createCsrfState(),
    redirectUri: 'https://example.com/callback'
);

// Get access token
$accessToken = $tiktok->getAccessToken($authorizationCode);

// Get user info
$userInfo = $tiktok->getUserInfo($accessToken['access_token'], [UserField::OpenID, UserField::Displayname]);

State of the project

This package is in early development stage. Not all endpoints are implemented yet.

License

This package is licensed under the MIT License.