-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.php
More file actions
27 lines (27 loc) · 744 Bytes
/
proxy.php
File metadata and controls
27 lines (27 loc) · 744 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
<?php
#https://www.sitepoint.com/php-xml-to-json-proxy/
ini_set('display_errors', true);
set_exception_handler('ReturnError');
$result = '';
$url = (isset($_POST['url']) ? $_POST['url'] : null);
if ($url){
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true
));
$result = curl_exec($ch);
curl_close($ch);
}
if ($result){
echo json_encode(new SimpleXMLElement($result));
} else {
returnError();
}
function returnError(){
echo'{"error":true}';
}
?>