array ( 'HTTP Response' => 400, 'Message' => 'Unknown Error' ), 1 => array ( 'HTTP Response' => 200, 'Message' => 'Success' ), 2 => array ( 'HTTP Response' => 403, 'Message' => 'HTTPS Required' ), 3 => array ( 'HTTP Response' => 401, 'Message' => 'Authentication Required' ), 4 => array ( 'HTTP Response' => 401, 'Message' => 'Authentication Failed' ), 5 => array ( 'HTTP Response' => 404, 'Message' => 'Invalid Request' ), 6 => array ( 'HTTP Response' => 400, 'Message' => 'Invalid Response Format' ) ); $filters =[]; if (isset ( $_GET ['unitID'] )) { $filters ['unitID'] = $_GET ['unitID']; } else { $filters ['unitID'] = '*'; } if (isset ( $_GET ['sampleType'] )) { $filters ['sampletype'] = $_GET ['sampleType']; } if (isset ( $_GET ['name'] )) { $filters ['fullScientificName'] = $_GET ['name']; } if (isset ( $_GET ['country'] )) { $filters ['country'] = $_GET ['country']; } if (isset ( $_GET ['isocountry'] )) { $filters ['countryisocode'] = $_GET ['isocountry']; } $config = SOLRQueryManager::getConfigDetails (); $query = SOLRQueryManager::createSearchQuery ( $config ); foreach ( $filters as $key => $value ) { $value = str_replace ( " ", "\ ", $value ); $value = str_replace ( "(", "\(", $value ); $value = str_replace ( ")", "\)", $value ); $value = str_replace ( ":", "\:", $value ); $q [] = SOLRQueryManager::getPartialQuery ( $key, $value, $filters, False ); } $fq=null; $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, implode ( " AND ", $q ), $fq, $filters, False ); $doc = $raw_response->getDocuments (); $numFound = $raw_response->getNumFound (); $status = $raw_response->getStatus(); // echo "Hello World! This is a first test for API RESTful Webservice on GGBN index. Data retrieved from SOLR index using portal queries. Yeah! // TODO: encoding somehow wrong, but hex-unicode seems to be a browser problem only; wt=xml looks strange, since json is output format; // can enforce wt=json, but than portal facet search is no longer working // check whether to use one SOLR core for portal and API or better two separate cores -> need specification what is required from // third parties such as EOL, GBIF, INSDC, and EDIT // If we can use same SOLR core for both would it be easier to use the web service for portal too? // Currently working parameters: unitID, sampleType, name, country, isocountry // "; $format = 'json'; $response = $doc; // $response ['code'] = 0; // $response ['status'] = $status; // echo $status; WebService::deliver_response ( $format, $response ); return; } }