gpt4 book ai didi

javascript - 如何确定用户是否订阅了 youtube channel

转载 作者:行者123 更新时间:2023-11-29 21:26:19 25 4
gpt4 key购买 nike

我的页面上有 youtube 订阅按钮 (iframe)。有什么办法可以知道访问该站点的用户是否已订阅?如果那不可能,也许有办法知道正在查看网站的某种用户 ID?

我发现当用户订阅时有一个属性

data-is-subscribed="true" 

对于按钮元素,但由于它来自 youtube 域,我无法以编程方式访问(至少我没有找到如何访问)iframe 源。

Blocked a frame with origin https://<my host ip> from accessing a frame with
origin https://<target host ip>. Protocols, domains, and ports must match.

谢谢

最佳答案

有两种方法可以检索用户的订阅:

  • To request a feed of the currently logged-in user's subscriptions, send a GET request to the following URL. Note: For this request, you must provide an authorization token, which enables YouTube to verify that the user authorized access to the resource.

https://gdata.youtube.com/feeds/api/users/default/subscriptions?v=2

*To request a feed of another user's subscriptions, send a GET request to the following URL. Note that this request does not require user authorization.

https://gdata.youtube.com/feeds/api/users/userId/subscriptions?v=2

在上面的 URL 中,您应该将文本 userId 替换为用户的 YouTube 用户 ID。为了向后兼容,API 还支持指定用户的 YouTube 用户名。

从这里您可以获得列表或空响应,这意味着用户没有订阅 channel 。您可以使用该列表来过滤他们是否已订阅。

关于javascript - 如何确定用户是否订阅了 youtube channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37333373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com