How can I retrieve YouTube video details from video URL using PHP?

前端 未结 9 702
南方客
南方客 2020-12-02 13:46

Using PHP, how can I get video information like title, description, thumbnail from a youtube video URL e.g.

http://www.youtube.com/watch?v=B4CRkpBGQzU
         


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 13:58

    Here is a function that can return several pieces of information. I included some sample properties, but others are available:

    microformat->playerMicroformatRenderer;
    }
    
    $o = youtube_info('2zPxY5WGG1E');
    
    var_dump(
       $o->title->simpleText,
       $o->description->simpleText,
       $o->thumbnail->thumbnails[0]->url
    );
    

    https://github.com/89z/sienna/blob/a5ba9109/youtube/youtube.php

提交回复
热议问题