-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.php
More file actions
31 lines (26 loc) · 911 Bytes
/
proxy.php
File metadata and controls
31 lines (26 loc) · 911 Bytes
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
<?php
//supress warnings & errors
error_reporting(0);
//sets the base of the url we want to hit
define ('HOSTNAME', 'http://www.ist.rit.edu/api');
//access the api - remember we have to send in a leading '/'
//so the path variable could be '/about/'
$url=HOSTNAME.$_GET['path'];
//set up curl (Client Uniform Resource Locator)
// Initiate curl
$ch = curl_init();
// allow us to include a header in the return (we are setting to false as we don't need to)
curl_setopt($session, CURLOPT_HEADER, false);
// Will return the response, if false it print the response (we want to capture it in a variable $result)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
//we want json back so set the correct mimetype
header("Content-Type: application/json");
//give it to me!
echo $result;
?>