尝试配置YouTube订阅按钮回调

尝试配置YouTube订阅按钮回调

本文介绍了尝试配置YouTube订阅按钮回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我尝试过的代码片段。

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


推荐答案

以下是解决此问题的Google错误:

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.

它甚至发生在Google自己的网站上:

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

这篇关于尝试配置YouTube订阅按钮回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:27