0
私はリモートWebサーバー上のWebサーバーアプリケーションのサンプルコード用にOAuth 2.0を使用しています。Google APIクライアントの承認:内部サーバーエラー500
ます。$ client->認証(...)
内部サーバーエラー500
、あなたが私にしてください助けることができる理由はありませんアイデアの原因は?ここで
は、Webアドレスです:http://imperiousgroup.com/gdrive/
そしてここではコードです:
あなたはPHPのバージョンを使用している//index.php
require_once(__DIR__ ."/api/vendor/autoload.php");
session_start();
$client = new Google_Client();
$client->setAuthConfig('client_secrets.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
$drive_service = new Google_Service_Drive($client);
$files_list = $drive_service->files->listFiles(array())->getItems();
echo json_encode($files_list);
} else {
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/gdrive/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
//oauth2callback.php
require_once __DIR__ .'/api/vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secrets.json');
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/gdrive/oauth2callback.php');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
if (!isset($_GET['code'])) {
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
$client->authenticate($_GET['code']);
}
読みやすくするために、コードをフォーマットしてください。ありがとう! – Alex