Akarin Asked: 2020-10-31 17:46:10 +0800 CST 2020-10-31 17:46:10 +0800 CST 2020-10-31 17:46:10 +0800 CST 如何从 youtube 视频中提取数据? 772 如何从 youtube 视频中获取数据?例如标题。 在互联网上,我发现几个代码在使用时出错或不完整。 php 1 Answers Voted Best Answer Dev. Joel 2020-10-31T18:24:57+08:002020-10-31T18:24:57+08:00 使用从那里返回or的oembed格式(它不仅适用于 Youtube),它会返回带有数据的关联,以便以后您可以单独获取它们。使用curl库JSONXMLArrayvídeo <?php /* Url del Video de Youtube*/ $url = "URLVIDEO"; $youtube = "http://www.youtube.com/oembed?url=". $url ."&format=json"; $recurso = curl_init($youtube); curl_setopt($recurso, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($recurso); curl_close($recurso); print_r(json_decode($return, true)); /* Acceder al Titulo */ print_r(json_decode($return, true)['title']); ?> 另一种方法是使用 Google API
使用从那里返回or的oembed格式(它不仅适用于 Youtube),它会返回带有数据的关联,以便以后您可以单独获取它们。使用curl库
JSON
XML
Array
vídeo