-
Notifications
You must be signed in to change notification settings - Fork 0
/
REST_Client.php
59 lines (51 loc) · 1.61 KB
/
REST_Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html>
<body>
<?php
error_reporting(E_ALL);
function curl_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
if (isset($_GET["action"]) && isset($_GET["id"]) && $_GET["action"] == "get_app")
{
$app_info = curl_get_contents('http://www.heigoldinvestments.com/rest_get/api.php?action=get_app&id=' . $_GET["id"]);
$app_info = json_decode($app_info, true);
?>
<table>
<tr>
<td>App Name: </td><td> <?php echo $app_info["app_name"] ?></td>
</tr>
<tr>
<td>Price: </td><td> <?php echo $app_info["app_price"] ?></td>
</tr>
<tr>
<td>Version: </td><td> <?php echo $app_info["app_version"] ?></td>
</tr>
</table>
<br />
<a href="http://www.heigoldinvestments.com/rest_get/REST_Client.php?action=get_app_list" alt="app list">Return to the app list</a>
<?php
}
else // else take the app list
{
echo "Simple REST Application. Choose one of the following applications for a description:<br>";
$app_list = curl_get_contents('http://www.heigoldinvestments.com/rest_get/api.php?action=get_app_list');
$app_list = json_decode($app_list, true);
?>
<ul>
<?php foreach ($app_list as $app): ?>
<li>
<a href=<?php echo "http://www.heigoldinvestments.com/rest_get/REST_Client.php?action=get_app&id=" . $app["id"] ?> alt=<?php echo "app" . $app["id"] ?>><?php echo $app["name"] ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php
} ?>
</body>
</html>