-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
37 lines (27 loc) · 1.03 KB
/
index.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
<?php
if(!isset($_REQUEST['endpoint']) || !isset($_REQUEST['query']) || !isset($_REQUEST['callback'])){
header("Content-type: text/html");
echo 'The variables <em>endpoint</em>, <em>query</em> and <em>callback</em> cannot be null. Parameters in request:<br />';
foreach($_REQUEST as $param => $value){
echo ($param . ": " . $value . "<br />");
}
die();
}
header("Content-type: application/javascript");
$req = $_REQUEST['endpoint'] . "?query=" . urlencode($_REQUEST['query']) . "&format=json";
//$stri=$_REQUEST['callback']."(";
// init cURL-Handle
$ch = curl_init();
// set URL and headers
curl_setopt($ch, CURLOPT_URL, $req);
curl_setopt($ch, CURLOPT_HEADER, false); // header output OFF
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/sparql-results+json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$source= curl_exec($ch);
// that's all folks
if(substr($source, 0, 1) !== "{") {
$source="{".$source."}";
}
curl_close($ch);
echo $_REQUEST['callback']."(".$source.")";
?>