【问题标题】:Missing execute() Method in YouTube Data APIYouTube 数据 API 中缺少 execute() 方法
【发布时间】:2013-10-16 19:41:12
【问题描述】:

我正在尝试访问 YouTube 数据 API,但 this sample code 似乎不起作用。

我的gradle构建文件如下:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.apis:google-api-services-youtube:v3-rev79-1.17.0-rc'
    compile 'com.google.api.client:google-api-client-googleapis:1.4.0-alpha'

}

我尝试使用的最小测试用例是:

YouTube youtube = new YouTube.Builder(new NetHttpTransport(), new GsonFactory(), new HttpRequestInitializer() {
    @Override
    public void initialize(com.google.api.client.http.HttpRequest httpRequest) throws IOException {}
}).setApplicationName("youtube-api").build();

YouTube.Search.List search = youtube.search().list("id");
search.setKey(API_KEY);
search.setQ("search string");
search.execute(); // execute() method does not exist

【问题讨论】:

    标签: java youtube-api


    【解决方案1】:

    显然我引用了错误版本的 google-api-client 库。正确的 gradle 构建脚本是:

    apply plugin: 'java'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.google.apis:google-api-services-youtube:v3-rev79-1.17.0-rc'
        compile 'com.google.api-client:google-api-client:1.17.0-rc'
        compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
    }
    

    【讨论】:

    猜你喜欢
    • 2020-11-30
    • 1970-01-01
    • 2012-01-03
    • 2020-01-21
    • 1970-01-01
    • 2020-10-25
    • 2019-06-08
    • 2016-01-25
    • 2016-07-12
    相关资源
    最近更新 更多