问题描述
在我的网络应用中,我必须要求用户获得访问其YouTube频道的权限.
In my web app, I have to ask the users for permission to access their YouTube channels.
身份验证网址是这样的:
The authentication url is something like this:
此URL提示用户选择YouTube频道.但是,在频道列表中,也会出现Google/YouTube帐户.此帐户未直接与任何渠道关联.
This URL prompts the user to choose a YouTube channel. But in the channel list, the Google/YouTube account also appears. This account isn't linked with any channels directly.
在我的应用中,用户应该只选择一个频道.我的问题是,如何确定用户是否选择了频道而不选择了Google/YouTube帐户? YouTube API中有什么方法可以帮助我知道吗?
In my app, the users are supposed to select only a channel. My question is, how can I tell if the user selected a channel and not the Google/YouTube account? Is there some method in the YouTube API that can help me know?
我注意到,如果用户选择了一个频道并调用了channel/list方法,则返回的信息与预期的一样,但是如果我选择了相同的方法选择了Google/YouTube帐户,则该频道的标题为空.但是我想知道是否还有其他(更清晰,更干净)的方法来判断用户是否选择了渠道或帐户.
I noticed that if the user has selected a channel and I call the channels/list method then the information it returns is as expected but if I call the same method having selected the Google/YouTube account then the channel title is empty. But I'd like to know if there is some other (nicer and cleaner) way to tell if the user has selected a channel or an account.
谢谢!
推荐答案
从youtube.channels.list(mine=true, part='snippet, status, contentDetails')
调用的响应中,您可以检查 status.isLinked 和 contentDetails.googlePlusUserId 以获得提示.如果未链接,则您有一个频道,如果已链接,则可能是其中一个.然后,您可以按照标题的方法进行操作,等等.对此没有明确的过滤条件.
From the response of youtube.channels.list(mine=true, part='snippet, status, contentDetails')
call, you can check status.isLinked and contentDetails.googlePlusUserId to get a hint. If it's not linked, you have a channel, if it's linked, it could be either of them. Then you can follow your title approach etc. There is not a definite filter for this.
如果您详细说明用例,也许我们可以建议一个更好的解决方案.
If you elaborate on your use case, maybe there is a better solution we can suggest.
这篇关于如何检查所选帐户是否为YouTube频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!