초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
32
instock/commonRequest.php
Normal file
32
instock/commonRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/session.php'; // 세션 파일 포함
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/mydb.php');
|
||||
|
||||
// 서비스 계정 JSON 파일 경로
|
||||
$serviceAccountKeyFile = $_SERVER['DOCUMENT_ROOT'] . '/tokens/mytoken.json';
|
||||
|
||||
// Google Drive 클라이언트 설정
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($serviceAccountKeyFile);
|
||||
$client->addScope(Google_Service_Drive::DRIVE);
|
||||
|
||||
// Google Drive 서비스 초기화
|
||||
$service = new Google_Service_Drive($client);
|
||||
|
||||
// 특정 폴더 확인 함수
|
||||
function getFolderId($service, $folderName, $parentFolderId = null) {
|
||||
$query = "name='$folderName' and mimeType='application/vnd.google-apps.folder' and trashed=false";
|
||||
if ($parentFolderId) {
|
||||
$query .= " and '$parentFolderId' in parents";
|
||||
}
|
||||
|
||||
$response = $service->files->listFiles([
|
||||
'q' => $query,
|
||||
'spaces' => 'drive',
|
||||
'fields' => 'files(id, name)'
|
||||
]);
|
||||
|
||||
return count($response->files) > 0 ? $response->files[0]->id : null;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user