Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/YOURLS/YOURLS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorozhozh <ozhozh@12232710-3e20-11de-b438-597f59cd7555>2009-05-21 18:15:04 +0400
committerozhozh <ozhozh@12232710-3e20-11de-b438-597f59cd7555>2009-05-21 18:15:04 +0400
commitce48a01f2bc6a32841f1cf92c691be46041c71ba (patch)
treebfb68c7e69514f50d87330bb9b81456b4fb07e84 /yourls-api.php
parentbb901d6785dc0adbc217630542916e69fbb91f01 (diff)
Improving the API functions and API sample file to reflect the new auth system
git-svn-id: http://yourls.googlecode.com/svn/trunk@22 12232710-3e20-11de-b438-597f59cd7555
Diffstat (limited to 'yourls-api.php')
-rw-r--r--yourls-api.php24
1 files changed, 5 insertions, 19 deletions
diff --git a/yourls-api.php b/yourls-api.php
index 46dc85c6..cb6f7df7 100644
--- a/yourls-api.php
+++ b/yourls-api.php
@@ -1,27 +1,13 @@
<?php
-### Require Files
+define('YOURLS_API', true);
require_once( dirname(__FILE__).'/includes/config.php' );
-if (defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true)
- require_once 'includes/auth.php';
+if ( defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true )
+ require_once( dirname(__FILE__).'/includes/auth.php' );
+
$db = yourls_db_connect();
$return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'], $db );
-switch ( $_REQUEST['format'] ) {
- case 'json':
- header('Content-type: application/json');
- echo yourls_json_encode($return);
- break;
-
- case 'xml':
- header('Content-type: application/xml');
- echo yourls_xml_encode($return);
- break;
-
- case 'simple':
- default:
- echo $return['shorturl'];
- break;
-}
+yourls_api_output( $_REQUEST['format'], $return );
die(); \ No newline at end of file