The Post looks like this.
$data = array('icd9' => $icd9, 'cpt' => $cpt, 'session_id'=> $session_id);
$url = $api_location."rarity/".$session_id;
$params = array('http' => array('method' => 'POST', 'content' => $data));
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp){
return "Error";
}
$response = @stream_get_contents($fp);
$results = $response;//json_decode($response);
return $results;
The Block on the api_location server looks like this:
if ($_POST['session_id']){
$fh = fopen('/interaction/rarity_req/alive.txt','w');
fwrite($fh,'\r\n'.date("Y-m-d - H:i:s"));
fclose($fh);
$session_id = $_POST['session_id'];
$cpt = $_POST['cpt'];
$icd9 = $_POST['icd9'];
}else{
$fh = fopen('/interaction/rarity_req/died.txt','w');
fwrite($fh, '\r\n'.date("Y-m-d - H:i:s"));
fclose($fh);
}
Any Ideas? I know I could install cURL to do this, but was trying to avoid it if at all possible because this is so simple. Was basing it off of this blog post: http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/
Turn your data into a URL-encoded string: