1. Go to this page and download the library: Download ssovit/tiktok-api 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/ */
$api=new \Sovit\TikTok\Api(array(
"user-agent" => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36', // Valid desktop browser HTTP User Agent
"proxy-host" => false,
"proxy-port" => false,
"proxy-username" => false,
"proxy-password" => false,
"cache-timeout" => 3600 // 1 hours cache timeout
"cookie_file" => sys_get_temp_dir() . 'tiktok.txt', // cookie file path
"nwm_endpoint" => "https://my-api.example.com" // private api endpoint
"api_key" => "API_KEY" // see below on how to get API key
), $cache_engine=false);
// Example using WordPress transient as cache engine
Class MyCacheEngine{
function get($cache_key){
return get_transient($cache_key);
}
function set($cache_key,$data,$timeout=3600){
return set_transient($cache_key,$data,$timeout);
}
}