我想获取用户的 youtube usedID。使用 youTubeService 成功登录后。在 viewController:finishedWithAuth:error:
上,userID 返回 nil。
Code
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error
{
[viewController dismissViewControllerAnimated:YES completion:NULL];
if(error != nil){
NSLog(@"Authentication error: %@", error);
}
else {
// Authentication succeeded...
NSLog(@"%@",auth.accessToken);
NSLog(@"%@",auth.userID); //returns nil
}
}
请注意,我不是在询问 Google 电子邮件 ID 我想获取 youtube 用户 ID。
最佳答案
我相信您问的是“旧版”用户名。您无法从 channel 获取它。
但如果您知道用户名,则可以使用 channels.list(part="id", forUsername="username")
找到 channel
另一方面,用户名不是唯一的,在 API 上没有用处。您需要的是 channel ID。
如果您正在寻找要显示的标题,那么您可以使用 channel's title .
关于ios - 如何获取 youtube 帐户的用户 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20080321/