0

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.

Foxum
  • 3
  • 2

1 Answers1

1

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:

Hope this helps!

Community
  • 1
  • 1
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91