【问题标题】:How to insert Youtube comment using Google's API for PHP?如何使用 Google 的 PHP API 插入 Youtube 评论?
【发布时间】:2016-09-05 22:23:40
【问题描述】:

我安装了最新版本的 Google API for PHP。使用here 列出的示例,我尝试为视频插入评论。但是,它失败了:

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

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

【问题讨论】:

    标签: google-api youtube-api google-api-php-client youtube-data-api


    【解决方案1】:

    您可以查看documentation,了解如何在 YouTube API 中添加 cmets。

    以下code sample 演示了如何使用以下 API 方法来创建和管理 cmets:

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

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

    • 它调用带有parentId参数的comments.list方法来检索线程中的cmets。

    • 它在请求正文中调用comments.update方法来更新评论。

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

    也可以查看SO question 了解更多信息。

    【讨论】:

      猜你喜欢
      • 2015-09-20
      • 2015-08-23
      • 2018-10-28
      • 2017-11-29
      • 2018-12-03
      • 2019-08-11
      • 2018-11-06
      • 2016-08-27
      • 2020-01-03
      相关资源
      最近更新 更多