annotate dbAnnotRestClient.php @ 0:8129ff2290dd draft

Uploaded
author cheanney
date Thu, 16 Jul 2015 09:17:00 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
1 <?php
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
2 $restApiCall = "";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
3 $restParams = "";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
4
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
5 foreach ($argv as $val)
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
6 {
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
7 $arr = preg_split("/=/", $val);
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
8 if (strcmp('inputValues', $arr[0]) == 0){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
9 $inputvalues = $arr[1];
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
10 $restParams = $restParams . "&inputValues=$inputvalues";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
11 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
12 if (strcmp('annotations', $arr[0]) == 0){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
13 $annotations = $arr[1];
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
14 $restParams = $restParams . "&annotations=$annotations";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
15 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
16 if (strcmp('TaxonId', $arr[0]) == 0){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
17 $taxonid = $arr[1];
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
18 $restParams = $restParams . "&taxonId=$taxonid";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
19 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
20 else if (strcmp('fileType', $arr[0]) == 0){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
21 $fileType = $arr[1];
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
22 if ($fileType == 'xml'){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
23 $biodbnetRestApiCallCore = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.xml?method=dbannot&format=row";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
24 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
25 else{
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
26 $biodbnetRestApiCallCore = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=dbannot&format=row";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
27 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
28 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
29 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
30
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
31 $restApiCall = $biodbnetRestApiCallCore . $restParams;
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
32 $response = file_get_contents($restApiCall);
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
33
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
34 if ($fileType == 'xml' || $fileType == 'json'){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
35 print_r($response);
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
36 }elseif ($fileType == 'table'){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
37 $formattedResponse = json_decode($response, true);
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
38 echo "<html>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
39 echo "<br/><br/><b>bioDBnet: dbAnnot Result</b><br/>";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
40 echo "<table border=1>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
41 $fields = array_keys($formattedResponse[0]);
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
42 echo "<tr>";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
43 foreach ($fields as $f){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
44 echo "<th>$f</th>";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
45 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
46 echo "</tr>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
47 foreach ($formattedResponse as $key => $value){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
48 echo "<tr>";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
49 foreach ($value as $v){
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
50 echo "<td>$v</td>";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
51 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
52 echo "</tr>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
53 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
54 echo "</table>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
55 echo "</html>\n";
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
56 }
8129ff2290dd Uploaded
cheanney
parents:
diff changeset
57 ?>