<?php
require_once('includes/load.php');
$sql = "SELECT access_token, shop_id, refresh_token, code FROM shop WHERE platform_id = 1 AND access_token = ''";
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
    $row = $result->fetch_assoc();
    $shopId = $row['shop_id'];
    $code = $row['code'];
    $authResponse = getAuthShopee($shopId, $code);
    if ($authResponse[2] === false) {
        echo json_encode(["message" => "Failed to authenticate with Shopee Shop ID = " . $shopId, "response" => $authResponse[0]]);
    }
    echo $authResponse;
}