From 04bc86a0fef9810f808e7ac445b5aae84e18f440 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sun, 4 Nov 2018 01:29:56 -0600 Subject: [PATCH] Add plain API format --- includes/functions-api.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/functions-api.php b/includes/functions-api.php index 52ac47c..0bb0194 100644 --- a/includes/functions-api.php +++ b/includes/functions-api.php @@ -120,6 +120,17 @@ function yourls_api_output( $mode, $output, $send_headers = true, $echo = true ) $result = ''; switch ( $mode ) { + case 'plain': + if( $send_headers ) + yourls_content_type_header( 'text/plain' ); + $result = sprintf( + "STATUS: %s\r\nCODE: %s\r\nURL: %s\r\nTITLE: %s\r\nSHORT: %s\r\nMESSAGE: %s\r\n", + $output["status"], $output["statusCode"], + $output["url"]["url"], yourls_trim_long_string($output["title"]), + $output["shorturl"], $output["message"] + ); + break; + case 'jsonp': if( $send_headers ) yourls_content_type_header( 'application/javascript' ); -- 2.42.0