已解决:在下面的链接中,我没有在步骤2中正确放置Drive.php。
我是php的新手,正在做一个将文件上传到谷歌驱动器的项目。首先,我遵循了谷歌开发者网站中给出的例子
面临几个问题:第一个问题是在步骤4中,我有多个帐户登录,通过点击一个帐户并接受,它应该会给我验证码,但我收到400个错误,说"无效请求,缺少必需的参数:redirect_uri"。在我修改了开发人员控制台中的项目条目,使其具有一个无法加载的伪重定向_uri,但我仍然可以从浏览器窗口中的URL参数访问验证码。这是一个黑客攻击,请让我知道是否有更好的方法来处理它(我应该在我的一端运行一个Web服务器来处理重定向url吗?)
第二个问题是:在成功验证后,它抛出了错误
PHP Fatal error: Uncaught exception 'Google_Exception' with message '(list) unknown parameter: 'pageSize'' in C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Resource.php:151
Stack trace:
#0 C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Drive.php(18 72): Google_Service_Resource->call('list', Array, 'Google_Service_...')
#1 C:'xampp'htdocs'driveapi'drivephp.php(82): Google_Service_Drive_Files_Resource->listFiles(Array)
#2 {main}
thrown in C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Resource.php on line 151
Fatal error: Uncaught exception 'Google_Exception' with message '(list) unknown parameter: 'pageSize'' in C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Resource.php on line 151
Google_Exception: (list) unknown parameter: 'pageSize' in C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Resource.php on line 151
Call Stack:
0.0008 135592 1. {main}() C:'xampp'htdocs'driveapi'drivephp.php:0
0.0408 2398408 2. Google_Service_Drive_Files_Resource->listFiles() C:'xampp'htdocs'driveapi'drivephp.php:82
0.0409 2399360 3. Google_Service_Resource->call() C:'xampp'htdocs'driveapi'vendor'google'apiclient'src'Google'Service'Drive.php:1872
其他详细信息:
Php版本:5.6.9(32位)
谷歌apiclient:尝试使用"Google/apiclient:1.*"answers"Google/aipclient:1.0.*@beta"
希望我清楚。提前谢谢。
当@avil对自己做出回应时,你必须"欺骗"composer版本,但你可以使用github版本,通过将其放在你的composer.json:中来避免修改供应商文件夹的内容
{
[...]
"repositories": [{
"type": "vcs",
"url": "https://github.com/google/google-api-php-client"
}],
"require": {
"google/apiclient": "dev-v1-master"
}
[...]
}