【问题标题】:How can i get the userID of the youtube account?如何获取 youtube 帐户的用户 ID?
【发布时间】:2013-11-19 19:26:30
【问题描述】:

我想获取用户 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。

【问题讨论】:

标签: ios objective-c youtube-api


【解决方案1】:

我相信您是在询问“旧版”用户名。您无法从频道中获取它。

但是如果你知道用户名,你可以找到channels.list(part="id", forUsername="username")的频道

另一方面,用户名不是唯一的,并且在 API 上没有用处。您需要的是频道 ID。

This guide describes it.

如果您正在寻找要显示的标题,则可以使用channel's title

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-08-12
  • 2016-06-19
  • 1970-01-01
  • 2016-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-29
相关资源
最近更新 更多