function makePutOrPostCurl($type, $data, $returnTransfer, $httpHeader, $url) { $ch = initCurl($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, $returnTransfer); $response = curl_exec($ch); curl_close($ch); return $response; }
$req .= '&disasterType=' . (isset($_REQUEST['disasterType']) ? $_REQUEST['disasterType'] : ""); $req .= '&satelliteName=' . (isset($_REQUEST['satelliteName']) ? $_REQUEST['satelliteName'] : ""); $req .= '&cursor=' . (isset($_REQUEST['nextRecord']) ? $_REQUEST['nextRecord'] : 1); $req .= '&maxResults=' . (isset($_REQUEST['numRecordsPerPage']) ? $_REQUEST['numRecordsPerPage'] : MSP_RESULTS_PER_PAGE); $proxyURL = 'catalogProxy'; if (isset($_REQUEST['proxyUrl']) && $_REQUEST['proxyUrl'] != "") { $proxyURL = $_REQUEST['proxyUrl']; } $req .= '&proxyUrl=' . $proxyURL; $req .= '&catalog=' . $catalogURL; $req .= '&catalogType=' . $catalogType; //$req = "catalog=http://disasterschartercatalog.org/ebrrcecec4/webservice&cursor=1&maxResults=10&startDate=&completionDate=&LLlat=-90&LLlon=-180&URlat=90&URlon=180&satelliteName=---&disasterStartDate=&disasterEndDate=&disasterType=&disasterActivationId=&disasterCallId=&catalogType=ebRR"; /** * Get POST data */ $curl = initCurl($catalogProxyURL); curl_setopt($curl, CURLOPT_URL, urldecode($catalogProxyURL)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $req); curl_setopt($curl, CURLOPT_POST, 1); $theData = curl_exec($curl); curl_close($curl); /* json result */ $json = json_decode($theData); $geojson = array('type' => 'FeatureCollection', 'totalResults' => isset($json->results) ? $json->results : 0, 'features' => array()); if (isset($json->rows)) { foreach ($json->rows as $row) { /* * Add feature */
/** * Get Remote data from url using curl * @param <String> $url */ function postRemoteData($url, $request, $setHeaders) { if (!empty($url)) { $curl = initCurl($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); if ($setHeaders) { // if $setHeaders is a boolean then add default HTTPHEADERS if (is_bool($setHeaders) === true) { curl_setopt($curl, CURLOPT_HTTPHEADER, array('POST HTTP/1.1', 'Content-type: text/xml;charset="UTF-8"', 'Accept: text/xml', 'Cache-Control: no-cache', 'Pragma: no-cache', 'Expect:')); } else { if (is_array($setHeaders) === true) { curl_setopt($curl, CURLOPT_HTTPHEADER, $setHeaders); } } } curl_setopt($curl, CURLOPT_POSTFIELDS, $request); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); $theData = curl_exec($curl); curl_close($curl); return $theData; } return ""; }