├── .gitignore ├── .styleci.yml ├── CHANGELOG.md ├── src ├── Contracts │ └── TikTokInterface.php ├── Facades │ └── TikTok.php ├── TikTokServiceProvider.php ├── TikTok.php ├── Models │ ├── DiscoverInfo.php │ ├── UserInfo.php │ ├── MusicInfo.php │ └── TagInfo.php └── Traits │ └── Header.php ├── resources └── lang │ ├── en │ └── tiktok.php │ └── ru │ └── tiktok.php ├── LICENSE.md ├── composer.json ├── CONTRIBUTING.md ├── README.md └── config └── tiktok.php /.gitignore: -------------------------------------------------------------------------------- 1 | /test.php 2 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | disabled: 4 | - single_class_element_per_statement -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `TikTok` will be documented in this file 4 | -------------------------------------------------------------------------------- /src/Contracts/TikTokInterface.php: -------------------------------------------------------------------------------- 1 | 'Data retrieval error', 6 | 'error_username' => 'Username error', 7 | 'error_tag' => 'Missing is Tag', 8 | 9 | 'user_no_found' => 'User is not found', 10 | 'music_no_found' => 'Music track not found', 11 | ]; 12 | -------------------------------------------------------------------------------- /resources/lang/ru/tiktok.php: -------------------------------------------------------------------------------- 1 | 'Ошибка получения данных', 6 | 'error_username' => 'Ошибка имени пользователя', 7 | 'error_tag' => 'Отсутствует хештег', 8 | 9 | 'user_no_found' => 'Пользователь не найден', 10 | 'music_no_found' => 'Музыкальная композиция не найдена', 11 | ]; 12 | -------------------------------------------------------------------------------- /src/Facades/TikTok.php: -------------------------------------------------------------------------------- 1 | publishes([ 17 | __DIR__.'/../config/tiktok.php' => config_path('tiktok.php'), 18 | ], 'config'); 19 | 20 | $this->publishes([ 21 | __DIR__.'/../resources/lang' => "{$this->app['path.lang']}/vendor/tiktok", 22 | ]); 23 | 24 | $this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'tiktok'); 25 | } 26 | 27 | /** 28 | * Register services. 29 | * 30 | * @return void 31 | */ 32 | public function register() 33 | { 34 | $this->mergeConfigFrom(__DIR__.'/../config/tiktok.php', 'tiktok'); 35 | 36 | $this->app->singleton('tiktok', function () { 37 | return $this->app->make(TikTok::class); 38 | }); 39 | 40 | $this->app->alias('tiktok', 'TikTok'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Daan 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "daaner/tiktok", 3 | "description": "TikTok scrapper for Laravel 7+", 4 | "keywords": [ 5 | "daaner", 6 | "tiktok", 7 | "tiktok-php", 8 | "tiktok-scrapper", 9 | "tiktok-parse", 10 | "laravel-tiktok" 11 | ], 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "name": "Daan", 16 | "email": "daan@ukr.net", 17 | "homepage": "https://github.com/daaner" 18 | }, 19 | { 20 | "name": "Kirill Astakhov", 21 | "email": "imkastahov@gmail.com", 22 | "homepage": "https://github.com/kastahov" 23 | } 24 | ], 25 | "require": { 26 | "php": ">=7.2.5", 27 | "laravel/framework": ">=7.0" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Daaner\\TikTok\\Facades\\": "src/Facades", 32 | "Daaner\\TikTok\\": "src" 33 | } 34 | }, 35 | "config": { 36 | "sort-packages": true 37 | }, 38 | "extra": { 39 | "laravel": { 40 | "providers": [ 41 | "Daaner\\TikTok\\TikTokServiceProvider" 42 | ], 43 | "aliases": { 44 | "TikTok": "Daaner\\TikTok\\Facades\\TikTok" 45 | } 46 | } 47 | }, 48 | "minimum-stability": "dev", 49 | "prefer-stable": true 50 | } 51 | -------------------------------------------------------------------------------- /src/TikTok.php: -------------------------------------------------------------------------------- 1 | primaryHeader = config('tiktok.primary_header'); 23 | } 24 | 25 | /** 26 | * This default response method. 27 | * 28 | * @param string $url 29 | * @param array|null $body 30 | * @param array|null $headers 31 | * 32 | * @return array 33 | */ 34 | public function getResponse($url, $body = null, $headers = null) 35 | { 36 | $header = $this->getHeader($headers); 37 | 38 | $response = Http::timeout(config('tiktok.tt_timeout')) 39 | ->retry(config('tiktok.tt_retry.number', 1), config('tiktok.tt_retry.time', 200)) 40 | ->withHeaders($header) 41 | ->get($url, $body); 42 | 43 | if ($response->failed()) { 44 | return [ 45 | 'success' => false, 46 | 'result' => null, 47 | 'info' => __('tiktok::tiktok.error_data'), 48 | ]; 49 | } 50 | 51 | $answer = $response->json(); 52 | 53 | return [ 54 | 'success' => true, 55 | 'result' => $answer, 56 | 'info' => '', 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Models/DiscoverInfo.php: -------------------------------------------------------------------------------- 1 | url = config('tiktok.discover_info.link'); 18 | $this->url_api = config('tiktok.discover_info.link_api'); 19 | } 20 | 21 | /** 22 | * @return array 23 | */ 24 | public function getDiscover() 25 | { 26 | /* add settings */ 27 | $this->ModelSettings(); 28 | 29 | $response = $this->getResponse($this->url); 30 | 31 | return $response; 32 | } 33 | 34 | /** 35 | * @param string $type 36 | * @param int|null $count 37 | * @param int|null $offset 38 | * @param bool $needItemList 39 | * @param bool $useRecommend 40 | * 41 | * $discoverType only 0 42 | * $keyWord not used 43 | * 44 | * @return array 45 | */ 46 | public function getDiscoverApi($type, $count = 20, $offset = 0, $needItemList = true, $useRecommend = false) 47 | { 48 | /* add settings */ 49 | $this->ModelSettings(); 50 | 51 | $body = [ 52 | 'offset' => $offset, 53 | 'count' => $count, 54 | 'needItemList' => $needItemList, 55 | 'useRecommend' => $useRecommend, 56 | 'keyWord' => '', 57 | 'discoverType' => 0, 58 | ]; 59 | 60 | $body = array_merge($body, config('tiktok.primary_body_api')); 61 | 62 | $response = $this->getResponse($this->url_api.$type, $body); 63 | 64 | return $response; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Models/UserInfo.php: -------------------------------------------------------------------------------- 1 | url = config('tiktok.user_info.link'); 19 | $this->arrayPrimary = config('tiktok.user_info.array_primary'); 20 | $this->arraySecondary = config('tiktok.user_info.array_secondary'); 21 | } 22 | 23 | /** 24 | * @param string $userName 25 | * @return array 26 | */ 27 | public function getUser($userName) 28 | { 29 | /* add settings */ 30 | $this->ModelSettings(); 31 | 32 | $userName = '@'.str_replace('@', '', $userName); 33 | 34 | if (! $userName) { 35 | return [ 36 | 'success' => false, 37 | 'result' => null, 38 | 'info' => __('tiktok::tiktok.error_username'), 39 | ]; 40 | } 41 | 42 | $response = $this->getResponse($this->url.$userName); 43 | 44 | return $response; 45 | } 46 | 47 | /** 48 | * @param string $userName 49 | * @return array 50 | */ 51 | public function getUserInfo($userName) 52 | { 53 | $data = $this->getUser($userName); 54 | 55 | $result = []; 56 | $result['success'] = $data['success']; 57 | 58 | if ($data['success'] && isset($data['result']['statusCode']) && $data['result']['statusCode'] == 0) { 59 | if (isset($data['result'][$this->arrayPrimary])) { 60 | $result['primary'] = $data['result'][$this->arrayPrimary]; 61 | } 62 | 63 | if ($this->arraySecondary && isset($data['result'][$this->arrayPrimary])) { 64 | $result['secondary'] = $data['result'][$this->arraySecondary]; 65 | } 66 | } else { 67 | $result['info'] = __('tiktok::tiktok.user_no_found'); 68 | $result['success'] = false; 69 | } 70 | 71 | return $result; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Models/MusicInfo.php: -------------------------------------------------------------------------------- 1 | url = config('tiktok.music_info.link'); 21 | $this->url_api = config('tiktok.music_info.link_api'); 22 | $this->api_field = config('tiktok.music_info.api_field'); 23 | $this->arrayPrimary = config('tiktok.music_info.array_primary'); 24 | $this->arraySecondary = config('tiktok.music_info.array_secondary'); 25 | } 26 | 27 | /** 28 | * @param string $music 29 | * @return array 30 | */ 31 | public function getMusic($music) 32 | { 33 | /* add settings */ 34 | $this->ModelSettings(); 35 | 36 | /* this hack id or name */ 37 | $music = '-'.substr(strrchr('-'.$music, '-'), 1); 38 | 39 | $response = $this->getResponse($this->url.$music); 40 | 41 | return $response; 42 | } 43 | 44 | /** 45 | * @param int $id 46 | * @param int|null $count 47 | * @param int|null $cursor 48 | * @return array 49 | */ 50 | public function getMusicApi($id, $count = 30, $cursor = 0) 51 | { 52 | /* add settings */ 53 | $this->ModelSettings(); 54 | 55 | $body = [ 56 | $this->api_field => $id, 57 | 'count' => $count, 58 | 'cursor' => $cursor, 59 | ]; 60 | 61 | $body = array_merge($body, config('tiktok.primary_body_api')); 62 | 63 | $response = $this->getResponse($this->url_api, $body); 64 | 65 | return $response; 66 | } 67 | 68 | /** 69 | * @param string $music 70 | * @return array 71 | */ 72 | public function getMusicInfo($music) 73 | { 74 | $data = $this->getMusic($music); 75 | 76 | $result = []; 77 | $result['success'] = $data['success']; 78 | 79 | if ($data['success'] && isset($data['result']['statusCode']) && $data['result']['statusCode'] == 0) { 80 | if (isset($data['result'][$this->arrayPrimary])) { 81 | $result['primary'] = $data['result'][$this->arrayPrimary]; 82 | } 83 | 84 | if ($this->arraySecondary && isset($data['result'][$this->arrayPrimary])) { 85 | $result['secondary'] = $data['result'][$this->arraySecondary]; 86 | } 87 | } else { 88 | $result['info'] = __('tiktok::tiktok.music_no_found'); 89 | $result['success'] = false; 90 | } 91 | 92 | return $result; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Models/TagInfo.php: -------------------------------------------------------------------------------- 1 | url = config('tiktok.tag_info.link'); 21 | $this->url_api = config('tiktok.tag_info.link_api'); 22 | $this->api_field = config('tiktok.tag_info.api_field'); 23 | $this->arrayPrimary = config('tiktok.tag_info.array_primary'); 24 | $this->arraySecondary = config('tiktok.tag_info.array_secondary'); 25 | } 26 | 27 | /** 28 | * @param string $tag 29 | * @return array 30 | */ 31 | public function getTag($tag) 32 | { 33 | /* add settings */ 34 | $this->ModelSettings(); 35 | 36 | $tag = str_replace('#', '', $tag); 37 | 38 | if (! $tag) { 39 | return [ 40 | 'success' => false, 41 | 'result' => null, 42 | 'info' => __('tiktok::tiktok.error_tag'), 43 | ]; 44 | } 45 | 46 | $response = $this->getResponse($this->url.$tag); 47 | 48 | return $response; 49 | } 50 | 51 | /** 52 | * @param int $id 53 | * @param int|null $count 54 | * @param int|null $cursor 55 | * @return array 56 | */ 57 | public function getTagApi($id, $count = 30, $cursor = 0) 58 | { 59 | /* add settings */ 60 | $this->ModelSettings(); 61 | 62 | $body = [ 63 | $this->api_field => $id, 64 | 'count' => $count, 65 | 'cursor' => $cursor, 66 | ]; 67 | 68 | $body = array_merge($body, config('tiktok.primary_body_api')); 69 | 70 | $response = $this->getResponse($this->url_api, $body); 71 | 72 | return $response; 73 | } 74 | 75 | /** 76 | * @param string $tag 77 | * @return array 78 | */ 79 | public function getTagInfo($tag) 80 | { 81 | $data = $this->getTag($tag); 82 | 83 | $result = []; 84 | $result['success'] = $data['success']; 85 | 86 | if ($data['success'] && isset($data['result']['statusCode']) && $data['result']['statusCode'] == 0) { 87 | if (isset($data['result'][$this->arrayPrimary])) { 88 | $result['primary'] = $data['result'][$this->arrayPrimary]; 89 | } 90 | 91 | if ($this->arraySecondary && isset($data['result'][$this->arrayPrimary])) { 92 | $result['secondary'] = $data['result'][$this->arraySecondary]; 93 | } 94 | } else { 95 | $result['info'] = __('tiktok::tiktok.user_no_found'); 96 | $result['success'] = false; 97 | } 98 | 99 | return $result; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! -------------------------------------------------------------------------------- /src/Traits/Header.php: -------------------------------------------------------------------------------- 1 | headers = array_merge($this->headers, $addition_headers); 18 | } 19 | 20 | return $this; 21 | } 22 | 23 | /** 24 | * @return array $headers 25 | */ 26 | public function getHeader($headers) 27 | { 28 | /* add UserAgent Header */ 29 | $this->getUserAgent(); 30 | $this->headers = array_merge($this->headers, ['user-agent' => $this->userAgent]); 31 | 32 | /* add from config - primary_header */ 33 | $this->headers = array_merge($this->headers, config('tiktok.primary_header')); 34 | 35 | /* add from config - use_header_referer */ 36 | if (config('tiktok.use_header_referer')) { 37 | $this->headers = array_merge($this->headers, config('tiktok.referer')); 38 | } 39 | 40 | /* add from config - use_header_lang */ 41 | if (config('tiktok.use_header_lang')) { 42 | $this->headers = array_merge($this->headers, config('tiktok.lang')); 43 | } 44 | 45 | /* add from config - use_header_browser */ 46 | if (config('tiktok.use_header_browser')) { 47 | $this->headers = array_merge($this->headers, config('tiktok.browser')); 48 | } 49 | 50 | /* add from config - use_header_browser_ver */ 51 | if (config('tiktok.use_header_browser_ver')) { 52 | $this->headers = array_merge($this->headers, config('tiktok.browser_ver')); 53 | } 54 | 55 | /* add from config - use_header_personal */ 56 | if (config('tiktok.use_header_personal')) { 57 | $this->headers = array_merge($this->headers, config('tiktok.personal')); 58 | } 59 | 60 | /* add from config - use_header_personal_addition */ 61 | if (config('tiktok.use_header_personal_addition')) { 62 | $this->headers = array_merge($this->headers, config('tiktok.personal_addition')); 63 | } 64 | 65 | /* add from config - verifyFp */ 66 | if (config('tiktok.verifyFp')) { 67 | $this->headers = array_merge($this->headers, ['verifyFp' => config('tiktok.verifyFp')]); 68 | } 69 | 70 | /* add Response headers */ 71 | if ($headers) { 72 | $this->headers = array_merge($this->headers, $headers); 73 | } 74 | 75 | return $this->headers; 76 | } 77 | 78 | /** 79 | * @param string $userAgent 80 | * @return this 81 | */ 82 | public function setUserAgent($userAgent) 83 | { 84 | $this->userAgent = $userAgent; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * @return string $this->userAgent 91 | */ 92 | public function getUserAgent() 93 | { 94 | if (! $this->userAgent) { 95 | $this->userAgent = config('tiktok.user_agent'); 96 | } 97 | 98 | return $this->userAgent; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel TikTok API 2 | 3 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/daaner/tiktok/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/daaner/tiktok/?branch=master) 4 | [![Laravel Support](https://img.shields.io/badge/Laravel-7+-brightgreen.svg)]() 5 | [![PHP Support](https://img.shields.io/badge/PHP-7.2.5+-brightgreen.svg)]() 6 | [![Latest Stable Version](https://poser.pugx.org/daaner/tiktok/v)](//packagist.org/packages/daaner/tiktok) 7 | [![Official Site](https://img.shields.io/badge/official-site-blue.svg)](https://tiktok.com/) 8 | [![Total Downloads](https://poser.pugx.org/daaner/tiktok/downloads)](//packagist.org/packages/daaner/tiktok) 9 | [![License](https://poser.pugx.org/daaner/tiktok/license)](//packagist.org/packages/daaner/tiktok) 10 | 11 | Scraper TikTok ([tiktok.com](https://tiktok.com/)) using this Laravel framework package ([Laravel](https://laravel.com)). 12 | 13 | 14 | #### Requirement 15 | - Laravel >= 7 16 | - PHP >= 7.2.5 17 | 18 | ## Install 19 | Install package. 20 | 21 | ``` bash 22 | composer require daaner/tiktok 23 | ``` 24 | 25 | 26 | Add provider and facade in `config/app.php`. 27 | 28 | ```php 29 | Daaner\TikTok\TikTokServiceProvider::class, 30 | 31 | // --- 32 | 'TikTok' => Daaner\TikTok\Facades\TikTok::class, 33 | ``` 34 | 35 | Publish the config and localization files with the command: 36 | 37 | ``` bash 38 | php artisan vendor:publish --provider="Daaner\TikTok\TikTokServiceProvider" 39 | ``` 40 | 41 | ## Configuration 42 | No special settings are needed. Queries also work with default settings. If you need finer settings, change the config file `config/tiktok.php` after 43 | If necessary, write the settings to a `.env`. 44 | 45 | 46 | ## Used 47 | Use the model you want and get an array. 48 | 49 | 50 | ## Model - UserInfo 51 | 52 | - `getUser($userName)` - Get user data by name (full array) 53 | - `getUserInfo($userName)` - Get simple user data by name (only main and secondary array) 54 | 55 | ```php 56 | use Daaner\TikTok\Models\UserInfo; 57 | 58 | $tt = new UserInfo; 59 | $user = $tt->getUser('tiktok'); 60 | //or 61 | $user = $tt->getUser('@tiktok'); 62 | // or for simple info 63 | $user = $tt->getUserInfo('tiktok'); 64 | 65 | dd($user); 66 | ``` 67 | 68 | 69 | ## Model - TagInfo 70 | 71 | - `getTag($tag)` - Get tag info 72 | - `getTagInfo($tag)` - Get tag simple info 73 | - `getTagApi($id, $count = 30, $cursor = 0)` - Get tag id data 74 | 75 | ```php 76 | use Daaner\TikTok\Models\TagInfo; 77 | 78 | $tt = new TagInfo; 79 | $tag = $tt->getTag('apple'); 80 | //or 81 | $tag = $tt->getTag('#apple'); 82 | // or for simple 83 | $tag = $tt->getTagInfo('apple'); 84 | 85 | //and API data 86 | $tag = $tt->getTagApi('13100', 10, 0); 87 | 88 | dd($tag); 89 | ``` 90 | 91 | 92 | ## Model - MusicInfo 93 | 94 | - `getMusic($music)` - Get music info 95 | - `getMusicInfo($music)` - Get music simple info 96 | - `getMusicApi($id, $count = 30, $cursor = 0)` - Get music id data (count shows 1 item less only this API query))))) 97 | 98 | ```php 99 | use Daaner\TikTok\Models\MusicInfo; 100 | 101 | $tt = new MusicInfo; 102 | $music = $tt->getMusic('I-JUST-FELL-6768866707013388289'); 103 | //or 104 | $music = $tt->getMusic('6768866707013388289'); 105 | // or for simple 106 | $music = $tt->getMusicInfo('6768866707013388289'); 107 | 108 | //and API data 109 | $music = $tt->getMusicApi('6728860413338847233', 10, 2); 110 | 111 | dd($music); 112 | ``` 113 | 114 | 115 | ## Model - DiscoverInfo 116 | 117 | - `getDiscover()` - Get discover info 118 | - `getDiscoverApi($type)` - Get Suggested data 119 | 120 | ```php 121 | use Daaner\TikTok\Models\DiscoverInfo; 122 | 123 | $tt = new DiscoverInfo; 124 | $discover = $tt->getDiscover(); 125 | 126 | //and API data 127 | $discover = $tt->getDiscoverApi('user'); 128 | //or 129 | $discover = $tt->getDiscoverApi('music'); 130 | //or 131 | $discover = $tt->getDiscoverApi('challenge'); 132 | 133 | dd($discover); 134 | ``` 135 | 136 | 137 | 138 | 139 | ## Changelog 140 | 141 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 142 | 143 | ## Contributing 144 | 145 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 146 | 147 | ## Credits 148 | 149 | - [Daan](https://github.com/daaner) 150 | - [Kirill](https://github.com/kastahov) 151 | - [All Contributors](../../contributors) 152 | 153 | ## License 154 | 155 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 156 | -------------------------------------------------------------------------------- /config/tiktok.php: -------------------------------------------------------------------------------- 1 | 3, 12 | 13 | 'tt_retry' => [ 14 | 'number' => 1, 15 | 'time' => 200, 16 | ], 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default headers primary 21 | |-------------------------------------------------------------------------- 22 | | 23 | | These are very important parameters 24 | | 25 | */ 26 | 27 | 'primary_header' => [ 28 | 'aid' => '1988', 29 | 'app_name' => 'tiktok_web', 30 | 'device_platform' => 'web', 31 | 'cookie_enabled' => 'true', 32 | ], 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Default body primary for API 37 | |-------------------------------------------------------------------------- 38 | | 39 | | These are very important parameters 40 | | 41 | */ 42 | 43 | 'primary_body_api' => [ 44 | 'aid' => '1988', 45 | 'app_name' => 'tiktok_web', 46 | 'device_platform' => 'web', 47 | 'language' => 'en', 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | Default User Agent 53 | |-------------------------------------------------------------------------- 54 | | 55 | | It is not necessary 56 | | 57 | */ 58 | 'user_agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36 OPR/72.0.3815.320', 59 | 60 | /* 61 | |-------------------------------------------------------------------------- 62 | | Referer headers 63 | |-------------------------------------------------------------------------- 64 | | 65 | | It is not necessary to change these parameters 66 | | 67 | */ 68 | 'use_header_referer' => false, 69 | 70 | 'referer' => [ 71 | 'referer' => 'https://www.tiktok.com/?lang=en', 72 | 'root_referer' => 'https://www.tiktok.com/?lang=en', 73 | 'page_referer' => 'https://www.tiktok.com/foryou?lang=en', 74 | 'uniqueId' => '', 75 | 'validUniqueId' => '', 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Lang headers 81 | |-------------------------------------------------------------------------- 82 | | 83 | | It is not necessary to change these parameters 84 | | For 'timezone_name' see https://www.php.net/manual/timezones.php 85 | | 86 | */ 87 | 'use_header_lang' => false, 88 | 89 | 'lang' => [ 90 | 'browser_language' => 'en', 91 | 'lang' => 'en', 92 | 'priority_region' => 'EN', 93 | 'region' => 'EN', 94 | 'tt-web-region' => 'EN', 95 | 'timezone_name' => 'Europe/London', 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Browser headers 101 | |-------------------------------------------------------------------------- 102 | | 103 | | It is not necessary to change these parameters 104 | | 105 | */ 106 | 'use_header_browser' => false, 107 | 108 | 'browser' => [ 109 | 'screen_width' => '1680', 110 | 'screen_height' => '1050', 111 | 'browser_online' => 'true', 112 | 'ac' => '4g', 113 | 'appType' => 'm', 114 | 'isAndroid' => 'false', 115 | 'isMobile' => 'false', 116 | 'isIOS' => 'false', 117 | ], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Browser version 122 | |-------------------------------------------------------------------------- 123 | | 124 | | It is not necessary to change these parameters 125 | | 126 | */ 127 | 'use_header_browser_ver' => false, 128 | 129 | 'browser_ver' => [ 130 | 'OS' => 'windows', 131 | 'browser_platform' => 'Win32', 132 | 'browser_name' => 'Mozilla', 133 | 'browser_version' => '5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36 OPR/72.0.3815.320', 134 | ], 135 | 136 | /* 137 | |-------------------------------------------------------------------------- 138 | | Personal headers NOT necessary 139 | |-------------------------------------------------------------------------- 140 | | 141 | | If you leave empty fields, the data will not be inserted 142 | | 143 | */ 144 | 'use_header_personal' => false, 145 | 146 | 'personal' => [ 147 | 'appId' => '1233', 148 | 'isUniqueId' => 'true', 149 | ], 150 | 151 | /* 152 | |-------------------------------------------------------------------------- 153 | | Personal addition headers NOT necessary 154 | |-------------------------------------------------------------------------- 155 | | 156 | | If you leave empty fields, the data will not be inserted 157 | | 158 | */ 159 | 'use_header_personal_addition' => false, 160 | 161 | 'personal_addition' => [ 162 | 'did' => '', 163 | 'uid' => '', 164 | 'sec_uid' => '', 165 | 'secUid' => '', 166 | ], 167 | 168 | /* 169 | |-------------------------------------------------------------------------- 170 | | Verify key NOT necessary 171 | |-------------------------------------------------------------------------- 172 | | 173 | | Copy this key from your browser DevTools 174 | | example: 'verify_khpjggvg_xXlMBl0E_DVRl_4ueQ_9Vcj_FbHc1BN5OrJF' 175 | | 176 | */ 177 | 'verifyFp' => '', 178 | 179 | /* 180 | |-------------------------------------------------------------------------- 181 | | Links and array settings 182 | |-------------------------------------------------------------------------- 183 | | 184 | | Moved into the settings, as it changes very often in the API 185 | | 186 | */ 187 | 188 | 'user_info' => [ 189 | /* full link must contain username '.../share/user/@tiktok' */ 190 | 'link' => 'https://www.tiktok.com/node/share/user/', 191 | 'array_primary' => 'userInfo', 192 | 'array_secondary' => 'metaParams', 193 | ], 194 | 195 | 'music_info' => [ 196 | /* example '.../share/music/I-JUST-FELL-6768866707013388289' */ 197 | 'link' => 'https://www.tiktok.com/node/share/music/', 198 | 'link_api' => 'https://m.tiktok.com/api/music/item_list/', 199 | 'api_field' => 'musicID', 200 | 'array_primary' => 'musicInfo', 201 | 'array_secondary' => 'metaParams', 202 | ], 203 | 204 | 'tag_info' => [ 205 | /* example '.../share/tag/apple' */ 206 | 'link' => 'https://www.tiktok.com/node/share/tag/', 207 | 'link_api' => 'https://m.tiktok.com/api/challenge/item_list/', 208 | 'api_field' => 'challengeID', 209 | 'array_primary' => 'challengeInfo', 210 | 'array_secondary' => 'metaParams', 211 | ], 212 | 213 | /* 214 | |-------------------------------------------------------------------------- 215 | | Suggested accounts 216 | |-------------------------------------------------------------------------- 217 | | 218 | | In API has lists: 'user', 'music', 'challenge' 219 | | 220 | */ 221 | 222 | 'discover_info' => [ 223 | 'link' => 'https://www.tiktok.com/node/share/discover/', 224 | 'link_api' => 'https://m.tiktok.com/api/discover/', 225 | ], 226 | 227 | ]; 228 | --------------------------------------------------------------------------------