getDatasetData.php
1.21 KB
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
<?php
/**
* @file getParameter.php
* @brief REST interface for service getParameter
*
*
* @version $Id: $
*/
ini_set("allow_url_fopen", true);
require_once '../config.php';
$amda_ws = new WebServer();
if (!$_GET["token"]) {
return array('success' => false, 'message' => "E01\nAuthentication is required for this webservice.");
}
if ($amda_ws->getNewToken()['token'] != $_GET["token"]) {
return array('success' => false, 'message' => "E02\nToken expired. Please authenticate again.");
}
$result = $amda_ws->getDataset($_GET);
if ($result['success']) {
$file = str_replace("http://oberoi.cesr.fr/AMDA-WS/", BASE_PATH, $result['dataFileURLs']);
if ($file) {
// header('Content-type: text/xml');
// $contenu = file_get_contents($file);
// error_log($contenu,3,'/home/natacha/TMP/tmp.xml');
// echo $contenu;
header('Content-type: text/xml');
$doc = new DOMDocument();
$doc->load($file);
echo $doc->saveXML();
}
} else {
$success = "false";
echo '<?xml version="1.0" encoding="UTF-8"?><getParameterResponse>';
echo '<success>' . $success . '</success>';
echo '<message>' . $result['message'] . '</message></getParameterResponse>';
}
?>