comparison dbAnnotRestClient.php @ 0:8129ff2290dd draft

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