Updated File Structure

This commit is contained in:
Hickmeister
2025-01-04 14:57:44 +00:00
parent b6da8a5ad5
commit 54007325c3
13 changed files with 120 additions and 117 deletions

View File

@@ -0,0 +1,27 @@
<?php
include '../session_check.php';
require '../envLoader.php'; // Load envLoader from php/
loadEnv(__DIR__ . '/../../../.env'); // Go up three levels to find .env
function refreshAccessToken() {
$tokens = json_decode(file_get_contents('etsyTokens.json'), true);
$refreshToken = $tokens['refresh_token'];
$data = [
'grant_type' => 'refresh_token',
'client_id' => $_ENV['ETSY_KEYSTRING'],
'client_secret' => $_ENV['ETSY_SECRET'],
'refresh_token' => $refreshToken
];
$ch = curl_init("https://api.etsy.com/v3/public/oauth/token");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
$newTokens = json_decode($response, true);
file_put_contents('etsyTokens.json', json_encode($newTokens));
echo "Token refreshed successfully.";
}
?>