TikScraperPHP
TikScraperPHP copied to clipboard
How to get video ID by url?
Does your library provide this feature? Thanks!
<?php
namespace TikScraper\Helpers;
class Converter {
/**
* Gets a video's ID from a URL
*/
static public function urlToId(string $url): string {
$path = parse_url($url, PHP_URL_PATH);
$path_arr = explode('/', $path);
return $path_arr[count($path_arr) - 1];
}
}
You can just copy that code. Or use it.