From 369cdfefeb93a5d5e0c53ce1c8d47f352051b624 Mon Sep 17 00:00:00 2001 From: Ozh Date: Thu, 31 Jan 2013 21:27:59 +0000 Subject: [PATCH] Status header in API results git-svn-id: http://yourls.googlecode.com/svn/trunk@840 12232710-3e20-11de-b438-597f59cd7555 --- includes/functions-api.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/functions-api.php b/includes/functions-api.php index 0244bc0..e21f083 100644 --- a/includes/functions-api.php +++ b/includes/functions-api.php @@ -87,6 +87,15 @@ function yourls_api_output( $mode, $return ) { yourls_do_action( 'pre_api_output', $mode, $return ); + if( isset( $return['statusCode'] ) ) { + $code = $return['statusCode']; + } elseif ( isset( $return['errorCode'] ) ) { + $code = $return['errorCode']; + } else { + $code = 200; + } + yourls_status_header( $code ); + switch ( $mode ) { case 'jsonp': header( 'Content-type: application/javascript' ); -- 2.45.0