Youtube API 如何使用 GetUserUpload Method PHP 获取所有视频 ID


Youtube API how to fetch all video ID's by using GetUserUpload Method PHP

$this->youtube->getUserUploads();

如何从URL中提取VideoID有什么方法可以调用吗?

有什么建议吗?

我在任何地方都找到了这个函数......也许它有帮助。

public function youtube_id_from_url($url) {
    $pattern =
        '%^# Match any youtube URL
        (?:https?://)?  # Optional scheme. Either http or https
        (?:www'.)?      # Optional www subdomain
        (?:             # Group host alternatives
          youtu'.be/    # Either youtu.be,
        | youtube'.com  # or youtube.com
          (?:           # Group path alternatives
            /embed/     # Either /embed/
          | /v/         # or /v/
          | .*v=        # or /watch'?v=
          )             # End path alternatives.
        )               # End host alternatives.
        (['w-]{10,12})  # Allow 10-12 for 11 char youtube id.
        ($|&).*         # if additional parameters are also in query string after video id.
        $%x';
    $result = preg_match($pattern, $url, $matches);
    if (false !== $result) {
        return isset($matches[1]) ? $matches[1] : false;
    }
    return false;
}