我已经导入了正确的gradle项目...并且我可以使用“ Youtube”对象,但是无法访问其own API docs?中描述的方法
无法解析方法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'
答案 0 :(得分:0)
您需要与Credentials
结合使用,以获取YouTube
实例:
new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME)
.build();