好的,所以两个小时后我完成了:)
首先,我从 Cocoapods 安装了 iOS-GTLYouTube 和 SCFNetworking 框架。
然后在应用程序委托中......
#import <GTLYouTube.h>
然后提出请求...
GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
service.APIKey = @"my api key from google";
GTLQueryYouTube *query = [GTLQueryYouTube queryForPlaylistItemsListWithPart:@"contentDetails"];
query.playlistId = @"the playlist id I want to request";
GTLServiceTicket *ticket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
if (!error) {
GTLYouTubePlaylistItemListResponse *playlistItems = object;
for (GTLYouTubePlaylistItem *playlistItem in playlistItems) {
GTLYouTubePlaylistItemContentDetails *details = playlistItem.contentDetails;
NSLog(@"PlaylistItem video ID = %@", details.videoId);
}
} else {
NSLog(@"%@", error);
}
}];