setApplicationName('Google Sheets API PHP Quickstart'); $client->setScopes([Google_Service_Sheets::SPREADSHEETS, Google_Service_Drive::DRIVE]); $client->setAuthConfig("stellar-430709-1e97a08bdfd7.json"); $client->setAccessType('offline'); $client->setAccessToken("AIzaSyAAAkIgkUQPicl9MkAbBNmBImM2pD19KFU"); if ($client->isAccessTokenExpired()) { if ($client->getRefreshToken()) { $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); } else { $authUrl = $client->createAuthUrl(); printf("Open the following link in your browser:\n%s\n", $authUrl); print 'Enter verification code: '; $authCode = trim(fgets(STDIN)); $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); $client->setAccessToken($accessToken); if (!file_exists(dirname($tokenPath))) { mkdir(dirname($tokenPath), 0700, true); } file_put_contents($tokenPath, json_encode($client->getAccessToken())); } } return $client; } $client = getClientWithCredentials(); dd($client); $service = new Google_Service_Sheets($client); $spreadsheetId = '11McnNecoafCA-56qLJzODY3H8mx5LC89GKbfWSTiY_4'; $range = 'Sheet1!A1:E'; // Örnek aralık $response = $service->spreadsheets_values->get($spreadsheetId, $range); $values = $response->getValues(); $htmlContent = ''; // HTML içeriği burada oluşturulacak foreach ($values as $row) { $htmlContent .= implode(' ', $row) . '
'; } $placeholders = ['{joker_alan}']; $replacements = ['gerçek_değer']; $updatedContent = str_replace($placeholders, $replacements, $htmlContent); $range = 'Sheet1!A1'; // Başlangıç hücresi $values = [ [$updatedContent] // Tek hücrede tüm HTML içeriği ]; $body = new Google_Service_Sheets_ValueRange([ 'values' => $values ]); $params = [ 'valueInputOption' => 'RAW' ]; $service->spreadsheets_values->update($spreadsheetId, $range, $body, $params); $driveService = new Google_Service_Drive($client); $fileId = $spreadsheetId; $response = $driveService->files->export($fileId, 'application/pdf', array( 'alt' => 'media' )); $filePath = 'path/to/save/yourfile.pdf'; file_put_contents($filePath, $response->getBody()->getContents()); use Illuminate\Support\Facades\Storage; Storage::put('public/pdfs/yourfile.pdf', file_get_contents($filePath)); ?>