Blame view

php/rest/getParameter.php 2.27 KB
16035364   Benjamin Renard   First commit
1
<?php
16035364   Benjamin Renard   First commit
2

70880168   Nathanael Jourdane   Add rate limit on...
3
/**
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
4
5
6
7
8
9
 * @api {get} getParameter.php getParameter
 * @apiDescription Provides data corresponding to a parameter chosen by the user among those available in AMDA (common
 * or user defined parameters).
 * @apiName getParameter
 * @apiGroup webservices
 *
6185ceeb   Myriam Bouchemit   update for apidoc
10
 * @apiParam {String} token The API token.
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
11
12
13
14
15
16
17
 * @apiParam {String} startTime Beginning of the time interval (ISO 8601 or UNIXTIME format).
 * @apiParam {String} stopTime End of the time interval (ISO 8601 or UNIXTIME format).
 * @apiParam {String} parameterID Identifier of the parameter, as defined in the file returned by the *getParameterList*
 * or *getObsDataTree* web-services.
 * @apiParam {String} [sampling] Sampling of data (*in seconds*).
 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*)
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
18
19
 * @apiParam {String} [outputFormat] Format of the returned file. Two options: `VOTable` and `ASCII`.
 * @apiParam {String} [timeFormat] Format of time in the data files. Two options: `ISO8601` and `UNIXTIME`.
6185ceeb   Myriam Bouchemit   update for apidoc
20
 * @apiParam {String} [gzip] `1` if the file must be compressed before delivery.
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
21
 *
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
22
23
24
 * @apiSuccess {String} success `true`
 * @apiSuccess {String} dataFileURLs URL of the files matching the criteria. If the file is empty, there is no data
 * matching these criteria.
0cb6a7aa   Myriam Bouchemit   add info for apidoc
25
 * @apiSuccess {String} status status of the job ( done | in_progress )
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
26
 *
ddedb507   Myriam Bouchemit   layout for apidoc
27
 * @apiSuccessExample Success-Response:
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
28
 *     HTTP/1.1 200 OK
0cb6a7aa   Myriam Bouchemit   add info for apidoc
29
30
31
 *     [success] => 1
 *     [dataFileURLS] => http://amda.irap.omp.eu/AMDA/data/WSRESULT/getparameter_c1_hia_dens_20130923T090000_20130924T130000.txt
 *     [status] => done
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
32
 *
ddedb507   Myriam Bouchemit   layout for apidoc
33
 * @apiErrorExample Error-Response:
6185ceeb   Myriam Bouchemit   update for apidoc
34
 * {"error":"Exception detected : Cannot find parameter local file c1_hia_dens1"}
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
35

70880168   Nathanael Jourdane   Add rate limit on...
36
 */
16035364   Benjamin Renard   First commit
37

5e2ea05e   Elena.Budnik   update REST
38
	require_once '../config.php';
16035364   Benjamin Renard   First commit
39

5e2ea05e   Elena.Budnik   update REST
40
41
42
43
44
45
46
	if (!key_exists("token", $_GET)) 
	{
		$result = array('success' => false, 'message' => "Authentication is required for this webservice.");
		exit(json_encode($result));
	} 
	
	$amda_ws = new WebServer();
70880168   Nathanael Jourdane   Add rate limit on...
47

5e2ea05e   Elena.Budnik   update REST
48
49
50
51
52
53
54
55
56
	if ($amda_ws->getNewToken()['token'] != $_GET["token"]) 
	{
		$result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again.");
	} else 
	{
		$result = $amda_ws->getParameter($_GET);
	}
	
	echo json_encode($result);
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
57
?>