Как настроить app.yaml для загрузки google-api-php-client на движке приложения?
Я пытался заставить клиента google api php работать на движке приложения. После прочтения ресурсов конфигурации app.yaml, предоставленных в документации, я все еще не смог заставить это работать. Мой app.yaml имеет google-api-php-client, как показано ниже:
- url: /google-api-php-client/(.*?)/(.*?)/(.*)
script: google-api-php-client/\3/\2/\1.php
И структура папки:
google-api-php-client->(some_folders)->(some_folders+files)->(some_files)
| level1 | | level2 | | level3 | | level4 |
Я хотел бы установить конфигурацию, чтобы иметь возможность доступа к файлам на уровне 3 и уровне 4 и выполнять вызовы require_once, например, так:
require_once ('/google-api-php-client/src/Google_Client.php');
require_once ('/google-api-php-client/src/contrib/Google_DriveService.php');
Я могу выполнять эти вызовы require_once на локальном хосте, но не при развертывании файлов в ядре приложения. Журналы на панели инструментов движка приложения показывают это:
PHP Fatal error: require_once(): Failed opening required '/google-api-php-client/src/Google_Client.php' (include_path='.;/base/data/home/apps/s~...
Буду признателен за любой вклад. Спасибо!
РЕДАКТИРОВАТЬ: я добавляю код, где ям с использованием require_once
require_once ('google-api-php-client/src/Google_Client.php');
require_once ('google-api-php-client/src/contrib/Google_DriveService.php');
session_start();
$client = new Google_Client();
$client->setApplicationName("Drive Demo");
$client->setClientId('****');
$client->setClientSecret('****');
$client->setRedirectUri('http://localhost:8080');
$client->setDeveloperKey('****');
$client->setScopes(array(
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile'));
$client->setAccessType('offline');
$service = new Google_DriveService($client);
$fileId = '****';
function printFile($service, $fileId) {
try {
$file = $service->files->get($fileId);
print_r($file);
print "Title: " . $file->getTitle();
print "Description: " . $file->getDescription();
print "MIME type: " . $file->getMimeType();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
function retrieveAllFiles($service) {
$result = array();
$pageToken = NULL;
do {
try {
$parameters = array('q'=>'', 'maxResults'=> '25', 'fields'=>'items(title,description,mimeType)');
if ($pageToken) {
$parameters['pageToken'] = $pageToken;
}
$files = $service->files->listFiles($parameters);
$result = array_merge($result, $files->getItems());
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
} while ($pageToken);
return $result;
}
if (!isset($_REQUEST['code']) && !isset($_SESSION['access_token'])) {
$authUrl = $client->createAuthUrl();
print("<a href="".$authUrl."">Authorize me</a>");
}else {
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
$_SESSION['access_token'] = $client->getAccessToken();
}
$files = retrieveAllFiles($service);
foreach($files as $file){
//print_r($file);
print "Title: " . $file->getTitle().'<br>';
print "Description: " . $file->getDescription().'<br>';
print "MIME type: " . $file->getMimeType().'<br>';
}
}
Обновление: удалено "/" согласно @Stuart 'Комментарий, который решил проблему.