更改Youtube API的发送网址(Changing Sending URL For Youtube API)

编程入门 行业动态 更新时间:2024-10-28 00:14:33
更改Youtube API的发送网址(Changing Sending URL For Youtube API)

我遇到了一个简单的问题,但我无法理解如何以及在何处实施此修复程序。 我目前有代码工作,它在我使用的网站的人民论坛签名中添加youtube订阅按钮。 问题是由API发送的网址发送Youtube.com/c/USERNAME或Youtube.com/Channel/USERNAME问题是这个网址对于小频道不一致并且使用频道用户名更加万无一失。 我正在尝试将/ 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部分之外,没有可见的代码真正的“代码”。

I came across a simple issue but I am having trouble understanding how and where to implement the fix. I currently have code working, it adds youtube subscribe button in peoples forum signature for site I use. Issue is the url being sent by API sends Youtube.com/c/USERNAME OR Youtube.com/Channel/USERNAME the problem is this URL is inconsistent for small channels and using Channel Username is more foolproof. I'm trying to change /c/ to /user/ and it would fix my issue.

This is the code I am referring to and using https://xenforo.com/community/threads/what-addon-youtube-sub-button-in-signature.88225/

What I believe is the problem @ https://apis.google.com/js/platform.js because there is no code real "code" visible other than message.customFields.youtube part.

最满意答案

尝试阅读有关YouTube订阅按钮的文档

通过YouTube订阅按钮,您可以向任意页面添加一键式“ Subscribe按钮。 该按钮可让用户订阅您的YouTube频道,而无需离开您的网站登录YouTube或确认其订阅。

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

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

您可以使用元素(例如<div>添加按钮,该元素将其class设置为g-ytsubscribe并使用其他属性来自定义按钮。 下面的代码显示了一个简单的集成,显示了GoogleDevelopers频道的“ Subscribe按钮。

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

必需属性

class - 将值设置为g-ytsubscribe 。 此类将<div>元素标识为订阅按钮的容器,并使YouTube能够动态调整嵌入按钮的大小,如下一节中所述。

您必须为以下两个属性之一指定值:

data-channel - 与按钮关联的通道的名称。 示例值: GoogleDevelopersdata-channelid - 与按钮关联的通道ID。 样本值: UC_x5XG1OV2P6uZZ5FSM9Ttw 。 您可以在YouTube帐户设置中或使用本文档末尾的API Explorer检索您的频道ID。 详细了解如何使用渠道ID 。

使用data-channelid

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

检索您的频道ID

要检索您自己的频道ID,请通过将表单顶部的“使用OAuth 2.0的授权请求”按钮设置为“开”来授权该请求。 然后单击表单底部的蓝色按钮发送请求。

要检索具有YouTube频道名称的任何频道的频道ID,请将下面表单中的forUsername属性设置为频道名称,将mine属性设置为false。

您可以使用的来源了解如何获取频道ID:

https://developers.google.com/youtube/v3/guides/working_with_channel_ids 检索“虚荣”频道的Youtube频道信息 https://developers.google.com/youtube/v3/code_samples/javascript

希望这可以帮助!

Try reading this document about 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.

To add a button, your application needs to load this JavaScript file:

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.

Using 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.

Sources you can use to understand how to get the Channel ID:

https://developers.google.com/youtube/v3/guides/working_with_channel_ids Retrieve Youtube Channel info for "Vanity" channel https://developers.google.com/youtube/v3/code_samples/javascript

Hope this helps!

更多推荐

本文发布于:2023-08-07 08:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463340.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   API   Youtube   URL   Sending

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!