如何使用Google的PHP接口插入Youtube评论?



我安装了适用于PHP的Google API的最新版本。使用这里列出的例子,我试图插入一个视频的评论。然而,它失败了:

Warning: require_once(/var/www/html/youtube/vendor/google/apiclient/src/Google/Service/YouTube.php): failed to open stream: No such file or directory in /var/www/html/youtube/vendor/google/apiclient/examples/comment_threads.php on line 15
Fatal error: require_once(): Failed opening required '/var/www/html/youtube/vendor/google/apiclient/src/Google/Service/YouTube.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/youtube/vendor/google/apiclient/examples/comment_threads.php on line 15

这是有道理的,因为在给定位置的Service文件夹中没有文件"Youtube.php"。代码建议应该有,所以我担心这些例子已经过时了。我正在使用版本2.0.0@RC谷歌API PHP(似乎是最新的)。所以,我的问题是:这些例子过时了吗(如果是,我应该如何插入Youtube评论?),还是这些例子很好,我做错了什么?

您可以查看此文档,了解如何在YouTube API中添加评论。

下面的代码示例演示了如何使用以下API方法来创建和管理注释:

  • 它调用带有videoId参数集的commentThreads.list方法来检索视频的评论。

  • 它调用带有parentId参数集的comments.insert方法来回复现有注释。

  • 它使用parentId参数调用comments.list方法来检索线程中的注释。

  • 它调用请求主体中带有注释的comments.update方法来更新注释。

  • 它调用comments.setModerationStatus方法来设置评论的审核状态,comments.markAsSpam方法来将评论标记为垃圾邮件,comments.delete方法来删除评论,使用id参数来识别评论。

还要查看此SO问题以了解更多信息。

最新更新