php - 尝试加载 YouTube PHP API 时找不到类
问题描述
我一直在尝试加载 YouTube API(通过 Google Client v2.5),但我一直遇到错误:
"error_message": "Class 'Google_Service_YouTube_Resource_Activities' not found",
"location": "[path snip]\/external\/google\/apiclient-services\/src\/Google\/Service\/YouTube.php:100"
作为测试,我尝试在GitHub 页面上运行基本示例,并且正确加载了 Books API。(请求失败,因为 Books 范围未注册到我的 API 密钥,但它确实正确加载并尝试调用。)因此,自动加载似乎正在工作,除了 YouTube API 每次都卡在这里。
尝试加载 API 的代码位于命名空间内的类的构造函数中:
$this->gclient = new \Google_Client();
$this->gclient->setApplicationName($settings['appname']);
$this->gclient->setDeveloperKey($settings['apikey']);
$this->gclient->addScope(\Google_Service_YouTube::YOUTUBE_READONLY);
$this->yclient = new \Google_Service_YouTube($this->gclient);
这些库是通过 PHP Composer 安装的,并且vendor
路径被修改为external
使用它的选项。服务器正在运行 PHP 7.3.19。
解决方案
原来,问题出在文件权限上。它现在可以运行,在运行chmod
修复后。
推荐阅读
- swagger - Nestjs Swagger - 在不同的路线上发布不同的 API 文档
- html - 如何在 Bootstrap 4 导航栏中悬停拆分按钮
- sass - 没有足够的 mixin 参数:SASS
- ios - iOS 应用程序更新未显示在搜索屏幕上,而仅显示在应用程序页面上,为什么?
- c++ - 错误 C2893 - 无法专门化函数模板 VS2019
- java - 如何从命令行覆盖配置文件属性
- javascript - Webpack 3 到 4 升级 __webpack_hmr 在页面加载时被中断
- javascript - 单击按钮时添加标签
- c - 服务器立即跳过 pin 搜索
- bamboo - Bamboo 中的“停止构建”按钮如何工作?