ssovit/tiktok-api
Composer 安装命令:
composer require ssovit/tiktok-api
包简介
Unofficial TikTok API for PHP
README 文档
README
Unofficial TikTok API for PHP
Not Working and Not Maintained
Looking for working TikTok Scraper API?
https://github.com/ssovit/tiktok-scraper with device registration routine, all the scrappers api endpoints available in python
Installation via Composer
composer require ssovit/tiktok-api
Looking for Watermark-less video API?
It's available on monthly subscription. See below for plans and contact details.
Usage
Follow examples in /example directory
Documentation
$api=new \Sovit\TikTok\Api(array(/* config array*/)); $trendingFeed=$api->getTrendingFeed($maxCursor=0); $userData=$api->getUser("tiktok"); $userFeed=$api->getUserFeed("tiktok",$maxCursor=0); $challenge=$api->getChallenge("foryourpage"); $challengeFeed=$api->getChallengeFeed("foryourpage",$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"); $noWatermark=$api->getNoWatermark("https://www.tiktok.com/@zachking/video/6829303572832750853");
Available Options
$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);
Cache Engine
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\TikTok\Api(array(/* config array*/),$cache_engine);
Stream and Download videos
Follow examples on /example folder for video stream and download example
Note: TikTok videos will not play directly when used in HTML video player as they require www.tiktok.com as http referrer.
Proxy Support
To use proxy, provide proxy-host, proxy-port, proxy-username, proxy-password
It's highly recommended that you use proxy to prevent your IP from getting banned.
It's highly recommended to use good Proxy service if you are making lots of requests in short interval of time. IPRoyal is good. It's my referral link and I would get a bit from it
Available methods
getTrendingFeed- Get trending feedgetTrendingFeed($maxCursor)getUser- Get profile data for TikTok UsergetUser($username)getUserFeed- Get user feed by IDgetUserFeed($user_id,$maxCursor)getUserFeedByName- Get user feed by NamegetUserFeedByName($username,$maxCursor)getChallenge- Get challenge/hashtag infogetChallenge($challenge)getChallengeFeed- Get challenge feed by IDgetChallengeFeed($challenge_id, $maxCursor)getChallengeFeedByName- Get challenge feed by namegetChallengeFeedByName($challenge,$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)getNoWatermark- Get no watermark for video by URLgetNoWatermark($video_url)(only works for videos before 28th July 2020). Private API server availbale on subscription that works for all TikTok posts
$maxCursor defaults to 0, and is offset for results page. maxCursor for next page is exposed on current page call feed data.
To-Do
- Save the Universe
- SOCKS proxy support
- Multiple proxy support (taking turns in round-robin. Act as rotating proxy)
Non-watermarked video url for newer videos
TikTok videos don't have video id as meta data on watermarked video posted after ~24-28 July 2020. Check below for subscription plans for non watermarked video API.
Discussion
- Discord https://discord.gg/rSQd2QAXA8
Empty results?
Use proxy. You are making too many API requests in short interval of time. Rotating proxy is recommended.
Want to improve this library? Want to contribute?
Don't hesitate to create pull requests.
Disclaimer
TikTok is always updating their API endpoints but I will try to keep this library whenever possible. I take no responsibility if you or your IP gets banned using this API. It's recommended that you use proxy.
ssovit/tiktok-api 适用场景与选型建议
ssovit/tiktok-api 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 37.42k 次下载、GitHub Stars 达 150, 最近一次更新时间为 2020 年 09 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「TikTok」 「tiktok-api」 「tiktok-scraper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ssovit/tiktok-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ssovit/tiktok-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ssovit/tiktok-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Aftership TikTok Shop extension for Magento 2. Allows connect with TikTok Shop and more.
TikTok scrapper for Laravel 7+
Full API Tiktok Data
sabri/tiktok is php Tiktok scraper
TikTok REST API wrapper for PHP
Custom TikTok scraper for video posts, photo posts and user profiles (PHP 8, PSR-4, Guzzle)
统计信息
- 总下载量: 37.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 150
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-25
