Trying to configure YouTube subscribe button callbacks

China☆狼群 提交于 2019-12-21 05:15:09

问题


Below is the snippet of the code which I have tried.

    <script src="https://apis.google.com/js/platform.js"></script>
    <script type="text/javascript">
      function onYtEvent(payload) {
        if (payload.eventType == 'subscribe') {
          // Add code to handle subscribe event.
            alert("hello world")
          });
        } else if (payload.eventType == 'unsubscribe') {
          // Add code to handle unsubscribe event.
          alert("asdf");
        }
        if (window.console) { // for debugging only
          window.console.log('YT event: ', payload);
        }
      }
    </script>
<div class="g-ytsubscribe" data-channelid="UCGsSHWM4ZraLZ8k6m4q4g-A" data-layout="default" data-count="hidden" data-onytevent="onYtEvent"></div>

The problem that I am facing is that it is not firing any event on clicking the subscribe button. In the console, I can see the following error-

Uncaught ReferenceError: __ytRIL is not defined

回答1:


Here is a Google bug tacking this issue: https://code.google.com/p/gdata-issues/issues/detail?id=8569

Please Star the bug so that it gets their attention.

It even happens on Google's own site: https://developers.google.com/youtube/youtube_subscribe_button



来源:https://stackoverflow.com/questions/39137734/trying-to-configure-youtube-subscribe-button-callbacks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!