Skip to content

Instantly share code, notes, and snippets.

@aGupieWare
Created October 29, 2014 05:56
Show Gist options
  • Select an option

  • Save aGupieWare/67e684a81cfeab54edff to your computer and use it in GitHub Desktop.

Select an option

Save aGupieWare/67e684a81cfeab54edff to your computer and use it in GitHub Desktop.
Deliver response logic for PHPlumbing api . . .
// Define HTTP responses //
$http_response_code = array(
200 => 'OK',
400 => 'Bad Request',
401 => 'Unauthorized',
403 => 'Forbidden',
404 => 'Not Found'
);
// Set HTTP Response //
header('HTTP/1.1 '.$api_response['status'].' '.$http_response_code[ $api_response['status'] ]);
// Process different content types //
if( strcasecmp($format,'json') == 0 ){
// JSON Response //
}elseif( strcasecmp($format,'xml') == 0 ){
// XML Response //
}else{
// HTML Response //
}
// End script process //
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment