Created
October 29, 2014 05:56
-
-
Save aGupieWare/67e684a81cfeab54edff to your computer and use it in GitHub Desktop.
Deliver response logic for PHPlumbing api . . .
This file contains hidden or 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
| // 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