]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-api.php
API improvements: stats
[Github/YOURLS.git] / yourls-api.php
1 <?php\r
2 define('YOURLS_API', true);\r
3 require_once( dirname(__FILE__).'/includes/config.php' );\r
4 if ( defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true )\r
5         require_once( dirname(__FILE__).'/includes/auth.php' );\r
6 \r
7 if ( !isset($_REQUEST['action']) )\r
8         die( 'Missing parameter "action"' );\r
9 \r
10 $db = yourls_db_connect();\r
11         \r
12 switch( $_REQUEST['action'] ) {\r
13 \r
14         case 'shorturl':\r
15                 $return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'], $db );\r
16                 unset($return['html']); // in API mode, no need for our internal HTML output\r
17                 break;\r
18         \r
19         case 'stats':\r
20                 $return = yourls_api_stats( $_REQUEST['filter'], $_REQUEST['limit'], $db );\r
21                 break;\r
22                 \r
23         default:\r
24                 die( 'Unknown "action" parameter' );\r
25 \r
26 }\r
27 \r
28 yourls_api_output( $_REQUEST['format'], $return );\r
29 \r
30 die();