API Wrapper for private API access
Via composer composer require ssovit/tiktok-private-api
Monthly subscription of my private API server is required for this to function. See below.
https://ssovit.github.io/TikTok-Private-API-PHP/
Follow examples in /example
directory
$api=new \Sovit\TikTokPrivate\Api(array(/* config array*/));
$trendingFeed=$api->getForYou($maxCursor=0);
$userData=$api->getUser("USERNAME");
$userFeed=$api->getUserFeed("USER_ID",$maxCursor=0);
$challenge=$api->getChallenge("CHALLENGE_ID");
$challengeFeed=$api->getChallengeFeed("CHALLENGE_ID",$maxCursor=0);
$musc=$api->getMusic("6798898508385585925");
$musicFeed=$api->getMusicFeed("6798898508385585925",$maxCursor=0);
$videoData=$api->getVideoByID("6829540826570296577");
$videoData=$api->getVideoByUrl("https://www.tiktok.com/@zachking/video/6829303572832750853");
// More to come
$api=new \Sovit\TikTokPrivate\Api(array(
"proxy" => '', // proxy in url format like http://username:password@host:port
"cache_timeout" => 3600 // 1 hours cache timeout
"transform_result" => true, // false if you want to get json without transforming it to more readable JSON structure
"api_key" => "API_KEY" // see below on how to get API key
), $cache_engine=false);
You can build your own engine that will store and fetch cache from your local storage to prevent frequent requests to TikTok server. This can help being banned from TikTok server for too frequent requests.
Cache engine should have callable get
and set
methods that the API class uses
// 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);
}
}
Usage
$cache_engine=new MyCacheEngine();
$api=new \Sovit\TikTokPrivate\Api(array(/* config array*/),$cache_engine);
getForYou
- Get trending feedgetForYou($maxCursor)
getUser
- Get profile data for TikTok UsergetUser($username)
getUserFeed
- Get user feed by IDgetUserFeed($user_id,$maxCursor)
getChallenge
- Get challenge/hashtag infogetChallenge($challenge)
getChallengeFeed
- Get challenge feed by IDgetChallengeFeed($challenge_id, $maxCursor)
getMusic
- Get music infogetMusic($music_id)
getMusicFeed
- Get music feedgetMusicFeed($music_id,$maxCursor)
getVideoByID
- Get video by IDgetVideoByID($video_id)
getVideoByUrl
- Get video by URLgetVideoByUrl($video_url)
- not all methods are documented, will update when I am free
$maxCursor
defaults to0
, and is offset for results page.maxCursor
for next page is exposed on current page call feed data.
No Longer Available