Skip to content

Instantly share code, notes, and snippets.

@haldun
Created August 13, 2013 20:01
Show Gist options
  • Save haldun/6225066 to your computer and use it in GitHub Desktop.
Save haldun/6225066 to your computer and use it in GitHub Desktop.
create a playlist via youtube api in ios
GTMOAuth2ViewControllerTouch *viewController = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:scope
clientID:clientId
clientSecret:clientSecret
keychainItemName:keychainItemName
completionHandler:
^(GTMOAuth2ViewControllerTouch *viewController, GTMOAuth2Authentication *auth, NSError *error) {
if (error) {
[SVProgressHUD showErrorWithStatus:error.localizedDescription];
} else {
GTLServiceYouTube *service = [FZMYoutubeSearchService sharedYoutubeService];
service.authorizer = auth;
GTLYouTubePlaylist *playlist = [[GTLYouTubePlaylist alloc] init];
GTLYouTubePlaylistSnippet *playlistSnippet = [[GTLYouTubePlaylistSnippet alloc] init];
playlistSnippet.title = @"this is my great playlist";
playlistSnippet.descriptionProperty = @"and this is description";
GTLYouTubePlaylistStatus *playlistStatus = [[GTLYouTubePlaylistStatus alloc] init];
playlistStatus.privacyStatus = @"private";
playlist.snippet = playlistSnippet;
playlist.status = playlistStatus;
GTLQueryYouTube *query = [GTLQueryYouTube queryForPlaylistsInsertWithObject:playlist part:@"snippet,status"];
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
if (error) {
NSLog(@"error: %@", error);
} else {
NSLog(@"response: %@", object);
}
}];
}
[self dismissViewControllerAnimated:NO completion:nil];
}];
[self presentViewController:viewController animated:YES completion:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment