gpt4 book ai didi

javascript - 更改 Youtube API 的发送 URL

转载 作者:行者123 更新时间:2023-12-03 06:33:00 25 4
gpt4 key购买 nike

我遇到了一个简单的问题,但我无法理解如何以及在哪里实现修复。我目前的代码正在运行,它在我使用的网站的人民论坛签名中添加了 YouTube 订阅按钮。问题是 API 发送的 url 发送 Youtube.com/c/USERNAME 或 Youtube.com/Channel/USERNAME 问题是此 URL 对于小 channel 来说不一致,并且使用 channel 用户名更加万无一失。我正在尝试将/c/更改为/user/它会解决我的问题。

这是我引用并使用的代码 https://xenforo.com/community/threads/what-addon-youtube-sub-button-in-signature.88225/

我认为问题是@ https://apis.google.com/js/platform.js因为除了 message.customFields.youtube 部分之外,没有可见的真正“代码”。

最佳答案

尝试阅读有关 YouTube Subscribe Button 的文档

The YouTube Subscribe Button lets you add a one-click Subscribe button to any page. The button lets people subscribe to your YouTube channel without having to leave your site to either log in to YouTube or confirm their subscriptions.

要添加按钮,您的应用程序需要加载此 JavaScript 文件:

https://apis.google.com/js/platform.js

You can add a button by using an element, such as a <div>, that sets its class to g-ytsubscribe and uses other attributes to customize the button. The code below shows a simple integration that displays a Subscribe button for the GoogleDevelopers channel.

<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-ytsubscribe" data-channel="GoogleDevelopers"></div>

Required attributes

  • class - Set the value to g-ytsubscribe. This class identifies the <div> element as a container for a subscription button and enables YouTube to dynamically resize the embedded button as explained in the next section.

  • You must specify a value for one of the following two attributes:

  • data-channel – The name of the channel associated with the button. Sample value: GoogleDevelopers.
  • data-channelid – The channel ID associated with the button. Sample value: UC_x5XG1OV2P6uZZ5FSM9Ttw. You can retrieve your channel ID in your YouTube account settings or by using the APIs Explorer at the end of this document. Learn more about working with channel IDs.

使用 data-channelid :

<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-ytsubscribe" data-channelid="UC_x5XG1OV2P6uZZ5FSM9Ttw"></div>

Retrieve your Channel ID

To retrieve your own channel ID, authorize the request by setting the Authorize requests using OAuth 2.0 button at the top of the form to ON. Then send the request by clicking the blue button at the bottom of the form.

To retrieve the channel ID for any channel that has a YouTube channel name, set the forUsername property in the form below to the channel name and the mine property to false.

可用于了解如何获取 channel ID 的来源:

希望这有帮助!

关于javascript - 更改 Youtube API 的发送 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38363606/

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