代码之家  ›  专栏  ›  技术社区  ›  Petro

无法解析方法getYouTubeService()

  •  0
  • Petro  · 技术社区  · 8 年前

    own API docs?

    enter image description here

    无法解析方法getYouTubeService()

      YouTube youtube = getYouTubeService();
            try {
                HashMap<String, String> parameters = new HashMap<>();
                //example
                parameters.put("id", "theid");
    
                YouTube.Subscriptions.Delete subscriptionsDeleteRequest = youtube.subscriptions().delete(parameters.get("id").toString());
                subscriptionsDeleteRequest.execute();
            }catch(Exception e){
                e.printStackTrace();
            }
    

    等级:

    //youtube api
    implementation 'com.google.apis:google-api-services-youtube:v3-rev205-1.24.1'
    // Dependency for Google Sign-In
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    
    // Dependencies for the REST API example
    implementation 'com.google.api-client:google-api-client:1.22.0'
    implementation 'com.google.api-client:google-api-client-android:1.22.0'
    implementation 'com.google.apis:google-api-services-people:v1-rev139-1.22.0'
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Gokul Nath KP    8 年前

    你需要使用如下 Credentials 得到 YouTube 实例:

    new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                    .setApplicationName(APPLICATION_NAME)
                    .build();
    

    参考: https://github.com/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/Quickstart.java