TikScraperPHP icon indicating copy to clipboard operation
TikScraperPHP copied to clipboard

How to get video ID by url?

Open devope opened this issue 2 years ago • 1 comments

Does your library provide this feature? Thanks!

devope avatar Jun 10 '22 17:06 devope

<?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.

NoPlagiarism avatar Oct 23 '22 13:10 NoPlagiarism