更新时间:2023-02-21 09:52:49
您的问题在 *** 数据 API 中经常出现(这里,最近在 SO 上多次解决:只需发出以下 SO 搜索查询:[***-data-api] forUsername
).
基本上,你必须承认两件事:
用户名是 API v3 的遗留功能;不是每个频道都有一个附加的;没有通道需要有一个连接.(请参阅 Google 员工于 2013 年 7 月 11 日发布的此官方声明.)>
如果您遇到形式为 https://www.***.com/c/NAME
(甚至 https://www.***.com/NAME
),则 NAME
不一定(尽管可能是)*** 频道的 *** 用户名.NAME
是频道的自定义网址
,一个不同的类别.(请参阅来自 Google 支持的此官方帐户.)
您的示例 -- impaulsive
-- 非常适合上面的第 2 点,因为它是 ID 为 UCGeBogGDZ9W3dsGx-mWQGJA 的频道的自定义 URL
,但不是任何频道的用户名:
$ python3 ***-search.py --custom-url impaulsiveUCGeBogGDZ9W3dsGx-mWQGJA$ python3 ***-search.py --user-name impaulsive***-search.py:错误:用户名impaulsive":找不到相关频道
上面使用的脚本 ***-search.py
是一个公共(MIT 许可)Python 3 程序(我开发的)实现了一个搜索自定义 URL 的算法并且也在查询用户名 API.
请注意,***-search.py
需要将有效的 API 密钥作为命令行选项 --app-key
的参数传递给它,否则,作为环境变量 ***_DATA_APP_KEY
传递.(使用命令行选项 --help
获取简要帮助信息.)
I am currently using the *** Data Channel API, which allows me to retrieve the Channel ID of any given username.
https://www.googleapis.com/***/v3/channels?key={KEY HERE}&forUsername={USERNAME}&part=id,snippet&order=date
It works for the majority of usernames, but for some reason it chooses not to work for others.
For example, if you visit the URL: https://***.com/impaulsive
, we can see that the username must be impaulsive
.
However, if you search that through the Channel API via the forUsername
attribute, it returns no results - even though it is their actual username and directs you to their official channel.
Is there a way to retrieve the Channel ID from a username?
Your issue is very much recurrent with *** Data API (here, on SO was recently tackled several times: just issue the following SO search query: [***-data-api] forUsername
).
Basically, you have to acknowledge two things:
User names are a legacy feature of the API v3; not every channel has one attached; no channel is required to have one attached. (See this official statement from Google staff from 2013-07-11.)
If you come across URLs of form https://www.***.com/c/NAME
(or even https://www.***.com/NAME
), then NAME
is not necessarily (though it could be) the *** user name of an *** channel. NAME
is a channel's custom URL
, a different category. (See this official account from Google support.)
Your example -- impaulsive
-- fits well with point 2 above, because it is the custom URL of the channel of which ID is UCGeBogGDZ9W3dsGx-mWQGJA
, yet is not the user name of any channel:
$ python3 ***-search.py --custom-url impaulsive
UCGeBogGDZ9W3dsGx-mWQGJA
$ python3 ***-search.py --user-name impaulsive
***-search.py: error: user name "impaulsive": no associated channel found
The script ***-search.py
used above is a public (MIT licensed) Python 3 program (that I developed) implementing an algorithm that searches for custom URLs and also is querying the API for user names.
Note that ***-search.py
requires a valid API key to be passed to it as argument of the command line option --app-key
or, otherwise, passed on as the environment variable ***_DATA_APP_KEY
. (Use the command line option --help
for brief helping info.)