PHP code example of needlaravelsite / tikapi-php

1. Go to this page and download the library: Download needlaravelsite/tikapi-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

needlaravelsite / tikapi-php example snippets


use NeedLaravelSite\TikApi\Facades\TikApi;

$response = TikApi::public()->explore()->list(5, 'us');

use NeedLaravelSite\TikApi\TikApi;

class TikApiController
{
    public function index(TikApi $tikapi)
    {
        return $tikapi->public()->video()->get('7109178205151464746');
    }
}



eedLaravelSite\TikApi\TikApi;

$tikapi = new TikApi();

$response = $tikapi->public()->check()->username('lilyachty');
print_r($response);

$tikapi = new TikApi('your_api_key', 'optional_account_key', 'https://api.tikapi.io');

$tikapi = new TikApi();

// 1️⃣ Get trending posts
$tikapi->public()->explore()->list(10, 'us');

// 2️⃣ Fetch posts by hashtag
$tikapi->public()->hashtag()->list(name: 'funny', count: 10);

// 3️⃣ Get video info
$tikapi->public()->video()->get('7109178205151464746', 'us');

// 4️⃣ Get comments and replies
$tikapi->public()->comments()->list('7109178205151464746');
$tikapi->public()->commentReplies()->list('7109178205151464746', '7109185042560680750');

// 5️⃣ Get music information
$tikapi->public()->musicInfo()->get('28459463');

// 6️⃣ Perform a search
$tikapi->public()->search()->general('lilyachty', 'us');

use NeedLaravelSite\TikApi\Exceptions\TikApiException;

try {
    $response = $tikapi->public()->video()->get('7109178205151464746');
} catch (TikApiException $e) {
    echo 'TikAPI Error: ' . $e->getMessage();
}
bash
composer 
bash
php artisan vendor:publish --provider="NeedLaravelSite\\TikApi\\TikApiServiceProvider" --tag=config

src/
├── Client/
│   └── HttpClient.php
├── Endpoints/
│   └── Public/
│        ├── Check.php
│        ├── CommentReplies.php
│        ├── Comments.php
│        ├── Explore.php
│        ├── Followers.php
│        ├── Following.php
│        ├── Hashtag.php
│        ├── Likes.php
│        ├── Music.php
│        ├── MusicInfo.php
│        ├── Posts.php
│        ├── Search.php
│        └── Video.php
├── Exceptions/
│   └── TikApiException.php
├── Facades/
│   ├── TikApi.php
│   └── TikApiServiceProvider.php
└── TikApi.php
bash
vendor/bin/phpunit tests/Feature/Public/SearchIntegrationTest.php