Blame view

php/rest/getDataset.php 2.48 KB
50fd9404   Elena.Budnik   getDataset()
1
<?php
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
2

50fd9404   Elena.Budnik   getDataset()
3
/**
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
4
 * @api {get} getDataset.php getDataset
6185ceeb   Myriam Bouchemit   update for apidoc
5
 * @apiDescription  Provides data corresponding to a dataset chosen by the user among those available in AMDA
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
6
7
 * @apiName getDataset
 * @apiGroup webservices
6185ceeb   Myriam Bouchemit   update for apidoc
8
9
10
11
12
13
14
15
16
17
 *
 * @apiParam {String} token The API token.
 * @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} datasetID Identifier of the dataset, as defined in the file returned by the  *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*)
 * @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`.
eb6baf5b   Myriam Bouchemit   gzip is boolean
18
 * @apiParam {Boolean} [gzip] `1` if the file must be compressed before delivery.
6185ceeb   Myriam Bouchemit   update for apidoc
19
 *
6185ceeb   Myriam Bouchemit   update for apidoc
20
21
22
 * @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
23
 * @apiSuccess {String} status status of the job ( done | in_progress )
6185ceeb   Myriam Bouchemit   update for apidoc
24
 *
ddedb507   Myriam Bouchemit   layout for apidoc
25
 * @apiSuccessExample Success-Response:
6185ceeb   Myriam Bouchemit   update for apidoc
26
 *     HTTP/1.1 200 OK
0cb6a7aa   Myriam Bouchemit   add info for apidoc
27
 *     [success] => 1
6185ceeb   Myriam Bouchemit   update for apidoc
28
 *     http://amda.irap.omp.eu/AMDA/data/WSRESULT/getdataset_ace-imf-all_20130923T090000_20130924T130000.txt
0cb6a7aa   Myriam Bouchemit   add info for apidoc
29
 *     [status] => done
6185ceeb   Myriam Bouchemit   update for apidoc
30
 *
ddedb507   Myriam Bouchemit   layout for apidoc
31
 * @apiErrorExample Error-Response:
6185ceeb   Myriam Bouchemit   update for apidoc
32
33
 * {"error":"Cannot find info file for dataset ace-imf-any"}

50fd9404   Elena.Budnik   getDataset()
34
35
36
 */
 
//ini_set("allow_url_fopen", true);
5e2ea05e   Elena.Budnik   update REST
37
	require_once '../config.php';
50fd9404   Elena.Budnik   getDataset()
38

5e2ea05e   Elena.Budnik   update REST
39
40
41
42
43
	if (!key_exists("token", $_GET)) 
	{
		$result = array('success' => false, 'message' => "Authentication is required for this webservice.");
		exit(json_encode($result));
	}
189a6f4f   Elena.Budnik   coorect timie
44
45
46
47
48
49
50
51
	
	if ($_GET['startTime'] && strpos($_GET['startTime'], ' ') !== false) 
	{
		$result = array('success' => false, 
					'message' => "Check that there is no + (plus) character in your time definition. + is a special character and should be encoded by %2B");
		exit(json_encode($result));
	}
	
5e2ea05e   Elena.Budnik   update REST
52
53
54
55
56
57
58
59
60
	$amda_ws = new WebServer();
	
	if ($amda_ws->getNewToken()['token'] != $_GET["token"]) 
	{
		$result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again.");
	} else 
	{
		$result = $amda_ws->getDataset($_GET);
	}
50fd9404   Elena.Budnik   getDataset()
61

5e2ea05e   Elena.Budnik   update REST
62
	echo json_encode($result);
b8194303   Elena.Budnik   getPlot final
63
?>