62Zi7sK2UPIYXPJKMZaAre changeset

Changeset363366303865 (b)
ParentNone (a)
ab
0+<?php
0+define('API_KEY', 'YOUR API KEY');
0+$base_url = "http://api.giantbomb.com/search/";
0+if(isset($_POST['q']))
0+{
0+    $fields = array();
0+    $fields['query'] = $_POST['q'];
0+    $fields['field_list'] = 'api_detail_url,resource_type,name,site_detail_url';
0+    $fields['api_key'] = API_KEY;
0+    $url = $base_url . '?' . http_build_query($fields);
0+    $data = file_get_contents($url);
0+    $xml = simplexml_load_string($data);
0+}
0+?>
0+<form method="post">
0+    <p>
0+        <input type="text" name="q" id="search_q" />
0+        <input type="submit" value="Search" />
0+    </p>
0+</form>
0+<?php if (isset($xml)): ?>
0+<h2>Results:</h2>
0+<ul>
0+    <?php foreach ($xml->results->children() as $item): ?>
0+    <li class="<?php echo htmlentities($item->resource_type) ?>">
0+        <a href="<?php echo htmlentities($item->site_detail_url) ?>"><?php echo htmlentities($item->name) ?></a>
0+    </li>
0+    <?php endforeach; ?>
0+</ul>
0+<?php endif ?>
...
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
--- Revision None
+++ Revision 363366303865
@@ -0,0 +1,30 @@
+<?php
+define('API_KEY', 'YOUR API KEY');
+$base_url = "http://api.giantbomb.com/search/";
+if(isset($_POST['q']))
+{
+ $fields = array();
+ $fields['query'] = $_POST['q'];
+ $fields['field_list'] = 'api_detail_url,resource_type,name,site_detail_url';
+ $fields['api_key'] = API_KEY;
+ $url = $base_url . '?' . http_build_query($fields);
+ $data = file_get_contents($url);
+ $xml = simplexml_load_string($data);
+}
+?>
+<form method="post">
+ <p>
+ <input type="text" name="q" id="search_q" />
+ <input type="submit" value="Search" />
+ </p>
+</form>
+<?php if (isset($xml)): ?>
+<h2>Results:</h2>
+<ul>
+ <?php foreach ($xml->results->children() as $item): ?>
+ <li class="<?php echo htmlentities($item->resource_type) ?>">
+ <a href="<?php echo htmlentities($item->site_detail_url) ?>"><?php echo htmlentities($item->name) ?></a>
+ </li>
+ <?php endforeach; ?>
+</ul>
+<?php endif ?>