如何在Gdata视频上传到您的管道中验证ID密码

时间:2012-08-29 10:21:19

标签: iphone youtube-api

要在你上传vedio我正在使用Gdata示例代码。

它的工作正常。但在我的应用程序中,我需要在用户尝试上传视频之前验证用户的用户名和密码。

我可以使用Gdata服务吗?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

以下是Youtube中客户端登录的方法:

- (BOOL)login:(NSString *)strusername password:(NSString *)strpassword
{
   NSMutableURLRequest *request = [NSMutableURLRequest 
                                requestWithURL:[NSURL URLWithString:@"https://www.google.com/accounts/ClientLogin"]];

   NSString *params = [[NSString alloc] initWithFormat:@"Email=%@&Passwd=%@&service=youtube&source=&continue=http://www.google.com/",username,password];
   [request setHTTPMethod:@"POST"];
   [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
   [params release];
   [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];

   NSHTTPURLResponse *response;
   NSError *error;
   [request setTimeoutInterval:120];
   NSData *replyData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];    

   NSString *replyString = [[[NSString alloc] initWithData:replyData encoding:NSUTF8StringEncoding] autorelease];
   if([replyString rangeOfString:@"Auth="].location!=NSNotFound)
   {
    NSString *authToken=[[replyString componentsSeparatedByString:@"Auth="] objectAtIndex:1];
    NSLog(@"Auth : %@",authToken);
    return YES;
   }
   else
   {
    return NO;
   }
 }
相关问题