Hello, I'm trying to extract a channel object from youtube api using the google-api library in xcode, this is the code I use:
//youtubeService type is GTLServiceYouTube youtubeService = [[GTLServiceYouTube alloc] init]; youtubeService.shouldFetchNextPages = YES; //auth is the object from the authentication callback youtubeService.authorizer = auth; videoQuery = [GTLQueryYouTube queryForChannelsListWithPart:@"RayWilliamJohnson"]; videoQuery.maxResults = 20; youtubeTicket = [youtubeService executeQuery:videoQuery completionHandler: ^(GTLServiceTicket *ticket, id channel, NSError *error) { NSLog(@" %@ ", error.description); NSLog(@"WIN! : %@ ", channel); }];
So far I have been getting this error:
Domain error = com.google.GTLJSONRPCErrorDomain Code = -32602 "operation could not be completed. (RayWilliamJohnson)" UserInfo = 0x7532c40 {error = RayWilliamJohnson, GTLStructuredError = GTLErrorObject 0x7533d30: {message: 1iam: "1iam:" iam: Joham ]}, NSLocalizedFailureReason = (RayWilliamJohnson)}
Any idea what throws this error?
Thanks in advance for your help!
Edit : I read the documentation in classes that simply βdon't existβ: P and checked out other examples that also follow the same approach.
Edit2 : ok I tried the following changes, and none of them worked :(, it worked for me, using the same example in the query explorer.
videoQuery.maxResults = 20; videoQuery.q = @"RayWilliamJohnson"; videoQuery.type = @"channel"; /*tried setting the part without calling the query method on GTLQueryYoutube but that did not work videoQuery.part = @"id";*/ videoQuery = [GTLQueryYouTube queryForChannelsListWithPart:@"id"]; //fetching only 20 items. youtubeTicket = [youtubeService executeQuery:videoQuery completionHandler: ^(GTLServiceTicket *ticket, id channel, NSError *error) { NSLog(@" %@ ", error.description); NSLog(@"WIN! : %@ ", channel); }];
the error is a little different, her saying that I did not specify any filters, even if I did.
Error Domain=com.google.GTLJSONRPCErrorDomain Code=-32602 "The operation couldn't be completed. (No filter selected.)" UserInfo=0x8870250 {error=No filter selected., GTLStructuredError=GTLErrorObject 0x88707f0: {message:"No filter selected." code:-32602 data:[1]}, NSLocalizedFailureReason=(No filter selected.)}
Edit3 : OK I changed a couple of things, at first I made a stupid mistake when I initialized my request after setting the parameters that just delete them. so the code now looks like this:
youtubeService.authorizer = auth; videoQuery = [GTLQueryYouTube queryForChannelsListWithPart:@"id"]; videoQuery.maxResults = 1; videoQuery.q = @"RayWilliamJohnson"; videoQuery.type = @"channel"; youtubeTicket = [youtubeService executeQuery:videoQuery completionHandler:^(GTLServiceTicket *ticket, GTLYouTubeChannel *channel, NSError *error) { NSLog(@" %@ ", error.description); NSLog(@"WIN! : %@ ", channel.description); }];
but I still get the error " no filters specified ", which means that the variables are not set anyway ...
Edit4 : ok after so many blondes that I managed to do this, it was a query object that I initialized, I tried to use a prefix specially created to search for channels, where Iβm supposed to just use queryForSearchListWithPart, so the working code looks like this:
youtubeService.authorizer = auth; videoQuery = [GTLQueryYouTube queryForSearchListWithPart:@"id"]; videoQuery.maxResults = 1; videoQuery.q = @"RayWilliamJohnson"; youtubeTicket = [youtubeService executeQuery:videoQuery completionHandler:^(GTLServiceTicket *ticket, GTLYouTubeChannel *channel, NSError *error) { NSLog(@" %@ ", error.description); NSLog(@"WIN! : %@ ", channel.description); }];
and provided this result:
2012-12-12 00: 17: 21.315 Test [13099: c07] (null) 2012-12-12 00: 17: 21.316 Test [13099: c07] WIN !: GTLYouTubeSearchListResponse 0x727f6d0: {pageInfo: {totalResults, resultsPerPage} ETag : "bm4JOKyioI0quSqrxEnI8H7snE4 / A2tE7ag9HxUC5HxeD2vDlGNg5iM" "nextPageToken: type" CAEQAA ": elements" youtube # searchListResponse ": [1]}
Thanks for helping Jeff