ikinci temizlik tamamlandı

This commit is contained in:
Ümit Tunç
2026-04-28 21:15:09 +03:00
parent f80443aec0
commit 37e7296527
8313 changed files with 2400677 additions and 0 deletions
@@ -0,0 +1,85 @@
<?php
use Google\Client as Google_Client;
use Google\Service\Sheets as Google_Service_Sheets;
use Google\Service\Drive as Google_Service_Drive;
function getClientWithCredentials() {
$client = new Google_Client();
$client->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) . '<br>';
}
$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));
?>