Skip to content

Instantly share code, notes, and snippets.

@haganbt
Created November 20, 2012 11:36
Show Gist options
  • Save haganbt/4117429 to your computer and use it in GitHub Desktop.
Save haganbt/4117429 to your computer and use it in GitHub Desktop.
DataSift Push API - PHP HTTP POST Receiver Examples
<?php
if (!function_exists('apache_request_headers')) {
function apache_request_headers() {
foreach($_SERVER as $key=>$value) {
if (substr($key,0,5)=="HTTP_") {
$key=str_replace(" ","-",ucwords(str_replace("_"," ",substr($key,5))));
$out[$key]=$value;
}
}
return $out;
}
}
$headers = apache_request_headers();
$filename = 'ds_' . $headers['X-DataSift-ID'];
$fh = fopen('/data/'. $filename, 'a+');
fwrite($fh, file_get_contents('php://input')."\n");
echo json_encode(array('success' => true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment