-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.php
55 lines (39 loc) · 1.51 KB
/
proxy.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
<?php
function web_request($url, $data = 0){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Set URL to getch
curl_setopt($ch, CURLOPT_URL, $url);
if ($data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}
$api_key = "lYfF8kAmPyRZ0Wr0G_9R";
$method = "/discovery_game/comparison/new";
$data = array('user' => 'ykgbzgtkdtfn');
$url = "http://$api_key:[email protected]/api/v1".$method;
$response = web_request($url, $data);
$obj = json_decode($response, true);
echo "<pre>".var_dump($obj)."</pre>";
echo "<fieldset style='width:500px;text-align:center;'><legend>Game</legend><br/>";
echo "<a href='".$obj['art1']['image']."'><img src='".$obj['art1']['image']."' /></a><br/><br/>";
echo "VS<br/><br/>";
echo "<a href='".$obj['art2']['image']."'><img src='".$obj['art2']['image']."' /></a><br/><br/>";
echo "</fieldset>";
?>