0% found this document useful (0 votes)
6 views2 pages

Hello

The document displays game data from an API call in a table with the game's name, description, genre, developer, and release date. It uses PHP and cURL to make the API request and JSON decode the response before outputting the data in a HTML table.

Uploaded by

Glemer Sebial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Hello

The document displays game data from an API call in a table with the game's name, description, genre, developer, and release date. It uses PHP and cURL to make the API request and JSON decode the response before outputting the data in a HTML table.

Uploaded by

Glemer Sebial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<!

DOCTYPE html>
<html>
<head>
<title>Game Data</title>
<style>
table {
border-collapse: collapse;
width: 100%;
font-family: Arial, sans-serif;
}

th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}

th {
background-color: #4CAF50;
color: white;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Game Data</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Genre</th>
<th>Developer</th>
<th>Release Date</th>
</tr>
</thead>
<tbody>
<?php
$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL =>
"https://mmo-games.p.rapidapi.com/game?id=452",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-RapidAPI-Host: mmo-games.p.rapidapi.com",
"X-RapidAPI-Key:
eee490547bmshd9ac74f2cf5c614p1b89e2jsna6605c6ffbd0"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "<tr><td colspan='5'>cURL Error #:" . $err .
"</td></tr>";
} else {
$data = json_decode($response, true);
echo "<tr>";
echo "<td>" . $data['name'] . "</td>";
echo "<td>" . $data['description'] . "</td>";
echo "<td>" . $data['genre'] . "</td>";
echo "<td>" . $data['developer'] . "</td>";
echo "<td>" . $data['release_date'] . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</body>
</html>

You might also like