【问题标题】:Android - How to use Youtube Data API to retrieve JSON result of a specific Youtube VideoAndroid - 如何使用 Youtube Data API 检索特定 Youtube 视频的 JSON 结果
【发布时间】:2016-03-03 08:36:59
【问题描述】:

我的 url 在浏览器中工作,它返回查询的 JSON 结果,获取有关 Youtube 视频的信息,但不明白如何使用 Youtube Data API 来传递此 JSON 并查看信息。

这是我正在使用的代码:

        YouTubeService service = new YouTubeService("app");
            //service.setUserCredentials("xxx","xxxxxx");
            String videoEntryUrl = String.format("https://www.googleapis.com/youtube/v3/videos?key=%s&part=snippet&id=%s"
                    , Config.YOUTUBE_API_KEY , (String) params[0]);
            VideoEntry videoEntry = service.g.getEntry(new URL(videoEntryUrl), VideoEntry.class);

我创建的 API 密钥是浏览器密钥,因此数据格式为 JSON。

我收到的错误是:

com.google.gdata.util.ParseException: Unrecognized content type:application/json;charset=UTF-8

【问题讨论】:

标签: java android youtube-api


【解决方案1】:

我认为您应该使用适用于 Java 的 YouTube 数据 API 客户端库来实现您的 Youtube。 请注意您可以使用的以下操作:

  • 列表
  • 插入
  • 更新
  • 删除

这样,对特定视频没有任何操作,但您可以使用列表操作。

您可以使用这些链接了解更多信息:

https://developers.google.com/api-client-library/java/apis/youtube/v3 https://developers.google.com/youtube/v3/code_samples/

另外,这里有一个item,您可以参考。

【讨论】:

    猜你喜欢
    • 2015-04-30
    • 2013-07-23
    • 2013-04-20
    • 1970-01-01
    • 2012-05-27
    • 2015-08-10
    • 2014-09-29
    • 2015-03-27
    • 2023-01-09
    相关资源
    最近更新 更多