【问题标题】:Is there a way to add a video to a Youtube playlist through Youtube API as a contributor?有没有办法通过 Youtube API 作为贡献者将视频添加到 Youtube 播放列表?
【发布时间】:2017-05-10 14:51:35
【问题描述】:

我正在尝试通过 Youtube API v3 添加视频作为贡献者,但我不断收到403 Forbidden 的回复,即使我是播放列表的贡献者。

我知道“贡献者”部分是问题所在,因为我可以使用相同的方法将任何视频添加到我创建的播放列表中。

这是我使用的代码(examples 中的代码相同):

    function addToPlaylist(id, plid) {
        var details = {
            videoId: id,
            kind: 'youtube#video'
        }

        var request = gapi.client.youtube.playlistItems.insert({
            part: 'snippet',
            resource: {
                snippet: {
                    playlistId: plid,
                    resourceId: details
                }
            }
        });

        request.execute(function(response) {
            if (typeof response.code === 'undefined') {
                console.log("video added to playlist.");
            } else {
                console.log("error adding video to playlist.");
            }
        });
    }

有办法吗?

【问题讨论】:

    标签: javascript api youtube-api


    【解决方案1】:

    嗯,基于YouTube Data API Errors,error 403 or forbidden error 意味着访问被禁止或者请求可能没有被正确授权。所以看来只有播放列表的拥有者才能做这个操作。

    如果对您有帮助,请查看这些 SO 问题。

    【讨论】:

      猜你喜欢
      • 2015-12-31
      • 1970-01-01
      • 2018-02-14
      • 2018-03-10
      • 2013-05-17
      • 1970-01-01
      • 1970-01-01
      • 2011-05-24
      • 1970-01-01
      相关资源
      最近更新 更多