2017-10-11 100 views

回答

1

花了我几天的时间找到解决方案。

首先,不要获取最新的Google API PHP客户端。

2.x版本开始使用Composer,并坦率地说,他们也开始变得太大,无法上传到共享主机。我确信主人喜欢这一点。对于某些人,您必须付费才能获得PHP客户端。

上传PHP客户端,是的,但是没有使用Composer的两年前版本:google-api-php-client v1.1.8。下载压缩文件,但您只需将您在此处看到的内容上传到名为“Google”的文件夹下:Google

接下来,请按照这篇文章PHP server-side YouTube V3 OAuth API video upload guide作为指南。他使用的是更旧的版本,但忽略了这一点。本文将帮助您解决这个问题。这是一个生命的救星。

我不知道为什么我无法使autoload.php与其spl_autoload_register('google_api_php_client_autoload');一起使用。现在,我只确定我需要的东西,通过试验和错误,其中包括以下“要求的语句”在我的代码开始:

<?php 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/autoload.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Config.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Auth/Abstract.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Auth/OAuth2.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Http/Request.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Utils.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Client.php'; 

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Service/YouTube.php'; 

include_once($_SERVER['DOCUMENT_ROOT'].'/src/CookieAPI.php'); 

session_start(); 

有!

你赢了!

相关问题