Get YouTube video title in PHP

后端 未结 7 1702
陌清茗
陌清茗 2021-01-22 22:44

In one of my applications I am saving a YouTube video\'s id... Like "A4fR3sDprOE". I have to display its title in the application. I got the following code for getting

7条回答
  •  滥情空心
    2021-01-22 22:53

    My solution is:

    $xmlInfoVideo = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos/" . $videoId . "?v=2&fields=title");
    
    foreach($xmlInfoVideo->children() as $title) {
        $videoTitle = strtoupper((string) $title); 
    }
    

    This get the title of the video.

提交回复
热议问题