'getregiondata', 'group' => $GROUP, 'data' => $query, 'password' => $PASSWORD ); # We now escape each key and value: this is very important, because the # data we send to Corrade may contain the '&' or '=' characters (we don't # in this example though but this will not hurt anyone). array_walk($params, function(&$value, $key) { $value = urlencode($key)."=".urlencode($value); } ); $postvars = implode('&', $params); #### # II. Set the options, send the request and then display the outcome. if (!($curl = curl_init())) return; curl_setopt($curl, CURLOPT_URL, $URL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); curl_setopt($curl, CURLOPT_ENCODING, true); $result = str_getcsv( urldecode( wasKeyValueGet( "data", curl_exec($curl) ) ) ); curl_close($curl); #### # III. Dump JSON for AJAX. echo json_encode( array_combine( wasArrayStride( $result, 2 ), wasArrayStride( array_slice( $result, 1 ), 2 ) ) ); ?>