【问题标题】:How to use Youtube feed in Windows Phone 7如何在 Windows Phone 7 中使用 Youtube 提要
【发布时间】:2012-05-27 10:49:44
【问题描述】:

我需要使用 youtube 网址,例如 http://www.youtube.com/user/nokia/feed 在我的 Windows Phone 7 应用程序中。我想下载 feed url 并相应地列出它。有人可以帮我做开胃菜吗?

【问题讨论】:

    标签: windows-phone-7


    【解决方案1】:

    Google 有一个API for YouTube,可让您从 Windows Phone 设备轻松执行此任务。根据 Google 的网站:

    关于 Google 数据 API

    数据 API 允许程序执行 YouTube 网站上提供的许多操作。可以搜索视频、检索标准提要并查看相关内容。程序还可以作为用户进行身份验证,以上传视频、修改用户播放列表等。

    Data API 主要面向使用服务器端语言进行编程的开发人员。它对于希望与 YouTube 进行深度集成的网站或应用程序非常有用,例如捕获视频并允许用户将该视频直接上传到 YouTube 的应用程序。 Data API 让您能够以编程方式访问 YouTube 视频和用户信息,使您能够使用用户的现有信息个性化您的应用程序,并代表他们执行操作,例如对视频进行评分或评论。

    开发人员指南解释数据 API 如何在基本级别使用 XML 和 HTTP 工作。本指南详细介绍了 YouTube API 服务器期望和返回的请求和响应。参考指南提供了有关这些请求和响应的结构的更多详细信息。参考指南定义了 API 的提要类型、HTTP 请求参数、HTTP 响应代码和 XML 元素。您可能还想了解 Google 数据协议和 Atom 发布协议,它们是构建数据 API 的标准。

    为了更轻松地使用 API,我们提供了许多客户端库,可将 API 抽象为特定语言的对象模型。这些客户端库是开源的,可以在 Apache License 2.0 下使用和修改。 Java.NETPHPPython开发者指南以及示例代码

    探索此页面YouTube API v2.0 - Understanding Feeds and Entries,其中指出:

    当您检索视频供稿或搜索结果列表时,YouTube 会返回一个 Atom 供稿,其中包含结果集中每个视频的一个标签。响应中的根 XML 标记将是标记。除了结果集中各个视频的信息外,Feed 还将包含列表中的结果总数、列表中第一项的索引、列表中的项数以及有关该列表的其他元数据。饲料。

    以下 XML 显示了包含视频供稿的 YouTube 数据 API 响应的格式:

    <?xml version='1.0' encoding='UTF-8'?>
    <feed xmlns='http://www.w3.org/2005/Atom'
        xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
        xmlns:gml='http://www.opengis.net/gml'
        xmlns:georss='http://www.georss.org/georss'
        xmlns:media='http://search.yahoo.com/mrss/'
        xmlns:batch='http://schemas.google.com/gdata/batch'
        xmlns:yt='http://gdata.youtube.com/schemas/2007'
        xmlns:gd='http://schemas.google.com/g/2005'
        gd:etag='W/&quot;CE4EQH47eCp7ImA9WxRQGEQ.&quot;'>
      <id>tag:youtube,2008:standardfeed:us:top_rated</id>
      <updated>2008-07-18T05:00:49.000-07:00</updated>
      <category scheme='http://schemas.google.com/g/2005#kind'
        term='http://gdata.youtube.com/schemas/2007#video'/>
      <title>Top Rated</title>
      <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo>
      <link rel='alternate' type='text/html'
        href='https://www.youtube.com/browse?s=tr'/>
      <link rel='http://schemas.google.com/g/2005#feed'
        type='application/atom+xml'
        href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2'/>
      <link rel='http://schemas.google.com/g/2005#batch'
        type='application/atom+xml'
        href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated/batch?v=2'/>
      <link rel='self' type='application/atom+xml'
        href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?...'/>
      <link rel='service' type='application/atomsvc+xml'
        href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?...'/>
      <link rel='next' type='application/atom+xml'
        href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?...'/>
      <author>
        <name>YouTube</name>
        <uri>http://www.youtube.com/</uri>
      </author>
      <generator version='2.0'
        uri='http://gdata.youtube.com/'>YouTube data API</generator>
      <openSearch:totalResults>100</openSearch:totalResults>
      <openSearch:startIndex>1</openSearch:startIndex>
      <openSearch:itemsPerPage>25</openSearch:itemsPerPage>
      <entry gd:etag='W/&quot;C0AMRn47eCp7ImA9WxRQGUw.&quot;'>
        <id>tag:youtube,2008:video:ZTUVgYoeN_b</id>
        <published>2008-07-05T19:56:35.000-07:00</published>
        <updated>2008-07-18T07:21:59.000-07:00</updated>
        <category scheme='http://schemas.google.com/g/2005#kind'
          term='http://gdata.youtube.com/schemas/2007#video'/>
        <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat'
          term='Shopping'/>
        <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat'
          term='parkas'/>
        <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat'
          term='People' label='People'/>
        <title>Shopping for Coats</title>
        <content type='application/x-shockwave-flash'
          src='http://www.youtube.com/v/ZTUVgYoeN_b?f=gdata_standard...'/>
        <link rel='alternate' type='text/html'
          href='https://www.youtube.com/watch?v=ZTUVgYoeN_b'/>
        <link rel='http://gdata.youtube.com/schemas/2007#video.responses'
          type='application/atom+xml'
          href='https://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/responses?v=2'/>
        <link rel='http://gdata.youtube.com/schemas/2007#video.ratings'
          type='application/atom+xml'
          href='https://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/ratings?v=2'/>
        <link rel='http://gdata.youtube.com/schemas/2007#video.complaints'
          type='application/atom+xml'
          href='https://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/complaints?v=2'/>
        <link rel='http://gdata.youtube.com/schemas/2007#video.related'
          type='application/atom+xml'
          href='https://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/related?v=2'/>
        <link rel='http://gdata.youtube.com/schemas/2007#mobile'
          type='text/html' href='https://m.youtube.com/details?v=ZTUVgYoeN_b'/>
        <link rel='http://gdata.youtube.com/schemas/2007#uploader'
          type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/_x5XG1OV2P6uZZ5FSM9Ttw?v=2'/>
        <link rel='self' type='application/atom+xml'
          href='https://gdata.youtube.com/feeds/api/standardfeeds/top_rated/v/ZTUVgYoeN_b?v=2'/>
        <author>
          <name>GoogleDevelopers</name>
          <uri>https://gdata.youtube.com/feeds/api/users/GoogleDevelopers</uri>
          <yt:userId>_x5XG1OV2P6uZZ5FSM9Ttw<</yt:userId>
        </author>
        <yt:accessControl action='comment' permission='allowed'/>
        <yt:accessControl action='commentVote' permission='allowed'/>
        <yt:accessControl action='videoRespond' permission='moderated'/>
        <yt:accessControl action='rate' permission='allowed'/>
        <yt:accessControl action='embed' permission='allowed'/>
        <yt:accessControl action='list' permission='allowed'/>
        <yt:accessControl action='autoPlay' permission='allowed'/>
        <yt:accessControl action='syndicate' permission='allowed'/>
        <gd:comments>
          <gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/comments'
            countHint='9416'/>
        </gd:comments>
        <georss:where>
          <gml:Point>
            <gml:pos>21.37124437061831 -157.87353515625</gml:pos>
          </gml:Point>
        </georss:where>
        <yt:hd/>
        <media:group>
          <media:category label='People'
            scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>People
          </media:category>
          <media:content 
            url='http://www.youtube.com/v/ZTUVgYoeN_b?f=gdata_standard...'
            type='application/x-shockwave-flash' medium='video'
            isDefault='true' expression='full' duration='215' yt:format='5'/>
          <media:content
            url='rtsp://rtsp2.youtube.com/ChoLENy73bIAEQ1kgGDA==/0/0/0/video.3gp'
            type='video/3gpp' medium='video'
            expression='full' duration='215' yt:format='1'/>
          <media:content
            url='rtsp://rtsp2.youtube.com/ChoLENy73bIDRQ1kgGDA==/0/0/0/video.3gp'
            type='video/3gpp' medium='video'
            expression='full' duration='215' yt:format='6'/>
          <media:credit role='uploader' scheme='urn:youtube'
              yt:display='GoogleDevelopers'>GoogleDevelopers</media:credit>
          <media:description type='plain'>
            What could make for more exciting video?
          </media:description>
          <media:keywords>Shopping, parkas</media:keywords>
          <media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license>
          <media:player url='https://www.youtube.com/watch?v=ZTUVgYoeN_b'/>
          <media:thumbnail url='http://img.youtube.com/vi/ZTUVgYoeN_b/2.jpg'
            height='90' width='120' time='00:00:03.500'/>
          <media:thumbnail url='http://img.youtube.com/vi/ZTUVgYoeN_b/1.jpg'
            height='90' width='120' time='00:00:01.750'/>
          <media:thumbnail url='http://img.youtube.com/vi/ZTUVgYoeN_b/3.jpg'
            height='90' width='120' time='00:00:05.250'/>
          <media:thumbnail url='http://img.youtube.com/vi/ZTUVgYoeN_b/0.jpg'
            height='360' width='480' time='00:00:03.500'/>
          <media:title type='plain'>Shopping for Coats</media:title>
          <yt:aspectRatio>widescreen</yt:aspectRatio>
          <yt:duration seconds='79'/>
          <yt:uploaded>2008-07-05T19:56:35.000-07:00</yt:uploaded>
          <yt:uploaderId>UC_x5XG1OV2P6uZZ5FSM9Ttw</yt:uploaderId>
          <yt:videoid>ZTUVgYoeN_b</yt:videoid>
        </media:group>
        <gd:rating min='1' max='5' numRaters='14763' average='4.93'/>
        <yt:recorded>2008-07-04</yt:recorded>
        <yt:statistics viewCount='383290' favoriteCount='7022'/>
        <yt:rating numDislikes='19257' numLikes='106000'/>
      </entry>
    </feed>
    

    作为替代方案,这可以通过解析 DOM 使用 HTML Agility Pack 来完成,但是在跳下悬崖进行 DOM 解析和/或将其与 Google YouTube API 结合使用之前,您应该探索上述解决方案。

    来源:Google

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多