PHPackages                             tiagoandre/tiktok-business-api-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tiagoandre/tiktok-business-api-sdk

ActiveLibrary[API Development](/categories/api)

tiagoandre/tiktok-business-api-sdk
==================================

Unofficial TikTok Business API SDK in PHP: This package provides a simple and unofficial interface for integrating with the TikTok Business API. Developed in PHP, it streamlines the connection with the platform, enabling developers to create and manage marketing campaigns, analyze performance metrics, and automate interactions with TikTok audiences efficiently. Ideal for businesses and agencies looking to enhance their marketing strategies on the world's most popular video social network.

0.0.4(1y ago)064MITPHPPHP ^8.3

Since Aug 26Pushed 1y agoCompare

[ Source](https://github.com/tiagoandrepro/tiktok-business-api-sdk)[ Packagist](https://packagist.org/packages/tiagoandre/tiktok-business-api-sdk)[ RSS](/packages/tiagoandre-tiktok-business-api-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

TikTok Business API SDK for PHP
===============================

[](#tiktok-business-api-sdk-for-php)

Este SDK em PHP permite a integração fácil com a TikTok Business API, facilitando a autenticação OAuth e a interação com as funcionalidades da API. Ele foi desenvolvido seguindo os padrões de design recomendados e é modular, tornando-o fácil de estender e manter.

Funcionalidades
---------------

[](#funcionalidades)

- **Autenticação OAuth 2.0**: Realize a autenticação e obtenha tokens de acesso para interagir com a API do TikTok.
- **Requisições HTTP Simples**: Envie requisições HTTP para a API do TikTok com classes estruturadas de `Request` e `Response`.
- **Manuseio de Exceções**: Lide com erros da API de forma robusta usando exceções personalizadas.

Instalação
----------

[](#instalação)

Primeiro, você precisa instalar o SDK via Composer:

```
composer require tiagoandrepro/tiktok-business-api-sdk
```

Uso Básico
----------

[](#uso-básico)

### 1. Configuração da Autenticação OAuth

[](#1-configuração-da-autenticação-oauth)

Primeiro, configure os detalhes do aplicativo TikTok e instancie as classes necessárias:

```
require 'vendor/autoload.php';

use Tiagoandrepro\TiktokBusinessApiSdk\Http\Client;
use Tiagoandrepro\TiktokBusinessApiSdk\Auth\OAuth;

$httpClient = new Client();

// Valores dinâmicos
$appId = 'SEU_APP_ID';
$clientSecret = 'SEU_APP_SECRET';
$redirectUrl = 'https://seu_dominio.com/callback';

// Instancia a classe OAuth com os valores dinâmicos
$oauth = new OAuth($httpClient, $appId, $clientSecret, $redirectUrl);

// Gera a URL de autorização dinamicamente
$authorizationUrl = $oauth->getAuthorizationUrl('random_state_string');
```

### 2. Troca do Código de Autorização pelo Token de Acesso

[](#2-troca-do-código-de-autorização-pelo-token-de-acesso)

Após o redirecionamento para o `redirectUri`, capture o código de autorização e troque-o por um token de acesso:

```
require 'vendor/autoload.php';

use Tiagoandrepro\TiktokBusinessApiSdk\Http\Client;
use Tiagoandrepro\TiktokBusinessApiSdk\Auth\OAuth;

$httpClient = new Client();

// Valores dinâmicos
$appId = 'SEU_APP_ID';
$clientSecret = 'SEU_APP_SECRET';
$redirectUrl = 'https://seu_dominio.com/callback';

$oauth = new OAuth($httpClient, $appId, $clientSecret, $redirectUrl);

// Receber o código de autorização que foi enviado pelo TikTok após a autenticação
$code = $_GET['code'] ?? null;

if ($code) {
    $accessTokenData = $oauth->getAccessToken($code);
}
```

### 3. Fazendo Requisições à API para Obter o Token de Acesso

[](#3-fazendo-requisições-à-api-para-obter-o-token-de-acesso)

Com o código de autorização, você pode trocar por um token de acesso:

```
use Tiagoandrepro\TiktokBusinessApiSdk\Http\Request;
use Tiagoandrepro\TiktokBusinessApiSdk\Http\Client;
use Tiagoandrepro\TiktokBusinessApiSdk\Exceptions\HttpException;

$httpClient = new Client();

public function getAccessToken(string $code): \Tiagoandrepro\TiktokBusinessApiSdk\Http\Response
{
    try {
        $request = new Request('POST', 'oauth2/access_token', [], [
            'app_id' => $this->appId,
            'secret' => $this->clientSecret,
            'auth_code' => $code,
            'grant_type' => 'authorization_code',
        ]);

        $response = $this->httpClient->request($request);

        if (isset($data['code']) && $data['code'] !== 0) {
            throw new HttpException("TikTok API Error: {$data['message']}");
        }

        return $response;
    } catch (\Exception $e) {
        throw new HttpException("Failed to retrieve access token", $e->getCode(), $e);
    }
}
```

Contribuindo
------------

[](#contribuindo)

Se você deseja contribuir com este projeto, por favor, siga estas etapas:

1. **Fork** o repositório.
2. Crie uma nova branch: `git checkout -b minha-feature`.
3. Faça suas alterações e **commit**: `git commit -m 'Adicionar nova feature'`.
4. **Push** para a branch: `git push origin minha-feature`.
5. Envie um **Pull Request**.

Licença
-------

[](#licença)

Este projeto é licenciado sob a [MIT License](LICENSE).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance43

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Total

4

Last Release

448d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8aadd12e7faa760aed943d3eb54d1987b665bfe2f56e9d3f8c9baaf8fc5fd3a9?d=identicon)[tiagoandrepro](/maintainers/tiagoandrepro)

---

Top Contributors

[![tiagoandrepro](https://avatars.githubusercontent.com/u/4328046?v=4)](https://github.com/tiagoandrepro "tiagoandrepro (10 commits)")

### Embed Badge

![Health badge](/badges/tiagoandre-tiktok-business-api-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/tiagoandre-tiktok-business-api-sdk/health.svg)](https://phpackages.com/packages/tiagoandre-tiktok-business-api-sdk)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
