PHP code example of restyler / tiktok-simple-scraper
1. Go to this page and download the library: Download restyler/tiktok-simple-scraper 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/ */
restyler / tiktok-simple-scraper example snippets
use TiktokScraper\Client;
$tiktokClient = new Client([
'rapidapi_key' => 'YOUR-RAPID-API_KEY'
]
);
$response = $tiktokClient->getUserInfo([
'username' => 'realmadrid',
// 'second-proxy' => '1', - use fallback proxy in case you see weird errors like 404 for existing accounts. Every method supports this.
]);
print_r($response);
// response now contains array of user info.
/*
Array
(
[secUid] => MS4wLjABAAAAdi4wJZtAiIre_rQ1KiFteDmtrGBDIyoleHRNsjL14-Enf8aVfkLUJ0l_LcJPZkiv
[userId] => 6693776501107033094
[isSecret] =>
[uniqueId] => realmadrid
[nickName] => Real Madrid C.F.
[signature] => ⚽️ The official Real Madrid C.F. account
🏆 13 times European Champions
[covers] => Array
(
[0] => https://p77-sign-sg.tiktokcdn.com/imgurl
[1] => https://p77-sign-sg.tiktokcdn.com/imgurl2
)
[coversMedium] => Array
(
[0] => https://p77-sign-sg.tiktokcdn.com/imgurl3
[1] => https://p77-sign-sg.tiktokcdn.com/imgurl4
)
[following] => 8
[fans] => 3800000
[heart] => 28900000
[video] => 338
[verified] => 1
[digg] => 0
[ftc] =>
[relation] => -1
[openFavorite] =>
) */
use TiktokScraper\Client;
$tiktokClient = new Client([
'rapidapi_key' => 'YOUR-RAPID-API_KEY'
]
);
$response = $tiktokClient->getUserFeed([
'username' => 'realmadrid',
'limit' => '10'
]);
print_r($response);
// response now contains array of user feed items.
use TiktokScraper\Client;
$tiktokClient = new Client([
'rapidapi_key' => 'YOUR-RAPID-API_KEY'
]
);
$response = $tiktokClient->getVideoInfo([
'url' => 'https://www.tiktok.com/@tuzelitydance/video/6867065857240026369?sender_device=pc&sender_web_id=6842368731214956037&is_from_webapp=1'
]);
print_r($response);
// response now contains video result.
use TiktokScraper\Client;
$tiktokClient = new Client([
'rapidapi_key' => 'YOUR-RAPID-API_KEY'
]
);
$response = $tiktokClient->getMusicInfo([
'url' => 'https://www.tiktok.com/music/Bad-Liar-6613051741099280390?lang=en'
]);
print_r($response);
// response now contains music result.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.