dongqing8765 2012-06-23 15:41
浏览 34

如何提取有关单个视频的信息 - Youtube API [重复]

This question already has an answer here:

There is an example how to search videos by search term in the documentation, but how to extract information from single video when you have the videoID.

<?php

  // set feed URL
    $feedURL = 'http://gdata.youtube.com/feeds/api/videos/LjhCEhWiKXk?v=2';

    // read feed into SimpleXML object
    $sxml = simplexml_load_file($feedURL);


// this get the video title
$videoTitle = $sxml->title;


?>

I get only the video title ... also there is no views count,description and duration.

</div>
  • 写回答

1条回答 默认 最新

  • doumei3828 2012-06-24 18:56
    关注

    This was useful for me: Visit Use the YouTube API with PHP

    You have to completely parse video entry ($sxml) to get more information:

    Children nodes of Entry $sxml:

    // get nodes in media: namespace for media information
    $media = $entry->children('http://search.yahoo.com/mrss/');
    

    Get duration: ($media->children ...)

    ** Element yt:duration under the media:group element stores the length of the video, in seconds**

    // get <yt:duration> node for video length
    $yt = $media->children('http://gdata.youtube.com/schemas/2007');
    $attrs = $yt->duration->attributes();
    $obj->length = $attrs['seconds'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题