' . htmlspecialchars(json_encode($json, JSON_PRETTY_PRINT)) . ''; } // Get current settings $settings = getRetroAchievementsSettings(); // Output page ?> RetroAchievements API Test

RetroAchievements API Test

Note: This test script uses the official RetroAchievements API at api.retroachievements.org which should bypass Cloudflare protection.

Current Configuration

Enabled:

Mode:

Username:

API Key:

Proxy URL:

Update Settings


isset($_POST['ra_enabled']), 'mode' => $_POST['ra_mode'], 'username' => $_POST['ra_username'], 'api_key' => $_POST['ra_api_key'], 'proxy_url' => $_POST['ra_proxy_url'], 'override_local_images' => $settings['override_local_images'] ?? true ]; if (saveRetroAchievementsSettings($newSettings)) { echo '

Settings saved successfully! Refresh the page to continue testing.

'; } else { echo '

Failed to save settings. Check file permissions.

'; } } ?>

Test API Connection

RetroAchievements integration is not enabled. Enable it in the settings above.

'; } else { echo '

Testing API Connection...

'; // Test with a simple console list API call $endpoint = 'GetConsoleIDs'; // Official endpoint for console list $params = []; $result = ($settings['mode'] === 'direct') ? raApiRequest($endpoint, $params) : raProxyRequest($endpoint, $params); if ($result) { echo '

API Connection successful!

'; echo '

Retrieved console data:

'; echo prettyJson($result); } else { echo '

API Connection failed. Check your settings and try again.

'; // Try to show detailed error information if ($settings['mode'] === 'direct') { $url = RA_API_BASE_URL . $endpoint . '.php?' . http_build_query([ 'z' => $settings['username'], 'y' => $settings['api_key'] ]); echo '

Attempted URL: ' . htmlspecialchars($url) . '

'; // Try a manual curl request for debugging $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, 'RetroHub/1.0'); curl_setopt($curl, CURLOPT_VERBOSE, true); $verboseLog = fopen('php://temp', 'w+'); curl_setopt($curl, CURLOPT_STDERR, $verboseLog); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error = curl_error($curl); rewind($verboseLog); $verboseOutput = stream_get_contents($verboseLog); curl_close($curl); echo '

HTTP Status Code: ' . $httpCode . '

'; if ($error) { echo '

Error: ' . htmlspecialchars($error) . '

'; } echo '

Verbose Log:

'; echo '
' . htmlspecialchars($verboseOutput) . '
'; if (!empty($response)) { echo '

Response:

'; echo '
' . htmlspecialchars($response) . '
'; } } else { // For proxy mode, show the proxy URL echo '

Proxy URL: ' . htmlspecialchars($settings['proxy_url']) . '

'; echo '

Check that your proxy server is correctly configured.

'; } } } } ?>

Search for Game Metadata

RetroAchievements integration is not enabled. Enable it in the settings above.

'; } else { $gameTitle = $_POST['game_title']; $console = $_POST['console']; echo '

Searching for: ' . htmlspecialchars($gameTitle) . ' (' . htmlspecialchars($console) . ')

'; // Get game metadata $metadata = getGameMetadata($gameTitle, $console); if ($metadata) { echo '

Game metadata found!

'; echo '

Metadata:

'; echo ''; echo '

Images:

'; echo '
'; if (isset($metadata['icon']) && $metadata['icon']) { echo '
'; echo '

Icon:

'; echo 'Game Icon'; echo '
'; } if (isset($metadata['screenshot_title']) && $metadata['screenshot_title']) { echo '
'; echo '

Title Screenshot:

'; echo 'Title Screenshot'; echo '
'; } if (isset($metadata['screenshot_ingame']) && $metadata['screenshot_ingame']) { echo '
'; echo '

Ingame Screenshot:

'; echo 'Ingame Screenshot'; echo '
'; } if (isset($metadata['screenshot_boxart']) && $metadata['screenshot_boxart']) { echo '
'; echo '

Box Art:

'; echo 'Box Art'; echo '
'; } echo '
'; echo '

Raw Data:

'; $gameData = getGameData($gameTitle, $console); echo prettyJson($gameData); } else { echo '

No metadata found for this game.

'; // Try to display more debugging information echo '

Debug Information:

'; echo '

Game title being searched: ' . htmlspecialchars($gameTitle) . '

'; echo '

Cleaned title: ' . htmlspecialchars(cleanGameTitle($gameTitle)) . '

'; // Try a direct API call to show available games $consoleId = $RA_CONSOLE_IDS[$console]; echo '

Attempting direct search using ConsoleID: ' . $consoleId . '

'; if ($settings['mode'] === 'direct') { $endpoint = 'GetGameList'; $params = [ 'i' => $consoleId, 'f' => cleanGameTitle($gameTitle), 'z' => $settings['username'], 'y' => $settings['api_key'] ]; $url = RA_API_BASE_URL . $endpoint . '.php?' . http_build_query($params); echo '

URL being requested: ' . htmlspecialchars($url) . '

'; $response = @file_get_contents($url); if ($response) { echo '

Direct API search returned data:

'; echo prettyJson($response); } else { echo '

Direct API search failed. Error: ' . error_get_last()['message'] . '

'; // Try curl as a fallback $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, 'RetroHub/1.0'); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($response) { echo '

Direct API search with curl returned data:

'; echo prettyJson($response); } else { echo '

Direct API search with curl failed. HTTP Status: ' . $httpCode . '

'; } } } else { echo '

Using proxy mode. Cannot show direct API call.

'; } } } } ?>

Clear Cache

Deleted ' . $deletedFiles . ' out of ' . $totalFiles . ' cache files.

'; echo '

Cache has been cleared. Try searching for a game again.

'; } ?>