简体   繁体   English

PHP Google驱动器文件列表不起作用

[英]PHP google drive files list doesn't work

<?php

require_once './src/Google_Client.php';
require_once './src/contrib/Google_DriveService.php';
$client = new Google_Client();
$client->setApplicationName("test");
$client->setClientId('test.apps.googleusercontent.com');
$client->setClientSecret('test');
$client->setRedirectUri('http://test.com/');
$client->setScopes(array('https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.readonly','https://www.googleapis.com/auth/drive.file','https://www.googleapis.com/auth/drive.metadata.readonly','https://www.googleapis.com/auth/drive.appdata','https://www.googleapis.com/auth/drive.apps.readonly'));

if(empty($_GET['code']))
{
    $client->authenticate();
}


$service = new Google_DriveService($client);
$client->setAccessToken($accessToken);
$accessToken = $client->authenticate($_GET['code']);


    $response = http_get("https://www.googleapis.com/drive/v2/files?q=mimeType+%3D+'audio%2Fmpeg'&fields=items(title%2CwebContentLink)&key=".$accessToken);
    print_r($response);


?>

this GET files list doesn't work. 此GET文件列表不起作用。

how can i get files list like that? 我如何获得这样的文件列表? mimetype : audio/mpeg and fields get title and webcontentlink. mimetype:音频/ MPEG和字段获取标题和webcontentlink。

Why are you building a GET request? 您为什么要建立GET请求? You should be using the API to list files 您应该使用API​​列出文件

I'm not 100% sure how to go about incorporating the information from the " Search for Files " doc, but rather than building that query directly like you are, you should be attempting to leverage the library. 我不是100%不确定如何合并“ Search for Files ”文档中的信息,但是您应该尝试利用该库,而不是像您一样直接构建该查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM