Get title from YouTube videos

前端 未结 17 1968
抹茶落季
抹茶落季 2020-12-07 17:30

I want to extract the Title of YouTube\'s videos. How can I do this?

Thanks.

17条回答
  •  日久生厌
    2020-12-07 17:50

    You can do using Json to get the all info about video

    $jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={Your_Video_ID_Here}&key={Your_API_KEY}8&part=snippet");
    $json = json_decode($jsonURL);
    
    $vtitle = $json->{'items'}[0]->{'snippet'}->{'title'};
    $vdescription = $json->{'items'}[0]->{'snippet'}->{'description'};
    $vvid = $json->{'items'}[0]->{'id'};
    $vdate = $json->{'items'}[0]->{'snippet'}->{'publishedAt'};
    $vthumb = $json->{'items'}[0]->{'snippet'}->{'thumbnails'}->{'high'}->{'url'};
    

    I hope it will solve your problem.

提交回复
热议问题