-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jokes.php
executable file
·47 lines (40 loc) · 894 Bytes
/
Jokes.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
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://08ad1pao69.execute-api.us-east-1.amazonaws.com/dev/random_ten");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// curl_setopt($ch, CURLOPT_HEADER, array('Content-Type:application/json'));
$response = curl_exec($ch);
$response = json_decode($response, true);
?>
<!DOCTYPE html>
<html>
<head>
<title>Jokes</title>
</head>
<body>
<h1>Your Jokes</h1>
<table border="1">
<tr>
<th>type of joke</th>
<th>setup</th>
<th>punchline</th>
</tr>
<?php
foreach ($response as $joke):
?>
<tr>
<td><?php echo $joke['type'] ?></td>
<td><?php echo $joke['setup'] ?></td>
<td><?php echo $joke['punchline'] ?></td>
</tr>
<?php
endforeach;
// echo"<pre>";
// print_r($response);
// echo "</pre>";
echo $err = curl_error($ch);
curl_close($ch);
?>
</table>
</body>
</html>