'authorization_code', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'code' => $code, 'redirect_uri' => $redirectUri ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']); $response = curl_exec($ch); curl_close($ch); $tokens = json_decode($response, true); // Salva os tokens em um arquivo de texto local if (isset($tokens['access_token'])) { file_put_contents('tokens.json', json_encode($tokens, JSON_PRETTY_PRINT)); } header('Content-Type: application/json; charset=utf-8'); echo json_encode($tokens, JSON_PRETTY_PRINT); exit; } echo "Aguardando código de autorização do Mercado Livre...";