Created
November 20, 2012 11:36
DataSift Push API - PHP HTTP POST Receiver Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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