yourls_get_db_stats(), 'statusCode' => 200, 'simple' => 'Need either XML or JSON format for stats', 'message' => 'success', ); return yourls_apply_filter( 'api_db_stats', $return ); } /** * Return array for API stat requests * */ function yourls_api_url_stats( $shorturl ) { $keyword = str_replace( YOURLS_SITE . '/' , '', $shorturl ); // accept either 'http://ozh.in/abc' or 'abc' $keyword = yourls_sanitize_string( $keyword ); $return = yourls_get_link_stats( $keyword ); $return['simple'] = 'Need either XML or JSON format for stats'; return yourls_apply_filter( 'api_url_stats', $return, $shorturl ); } /** * Expand short url to long url * */ function yourls_api_expand( $shorturl ) { $keyword = str_replace( YOURLS_SITE . '/' , '', $shorturl ); // accept either 'http://ozh.in/abc' or 'abc' $keyword = yourls_sanitize_string( $keyword ); $longurl = yourls_get_keyword_longurl( $keyword ); if( $longurl ) { $return = array( 'keyword' => $keyword, 'shorturl' => YOURLS_SITE . "/$keyword", 'longurl' => $longurl, 'title' => yourls_get_keyword_title( $keyword ), 'simple' => $longurl, 'message' => 'success', 'statusCode' => 200, ); } else { $return = array( 'keyword' => $keyword, 'simple' => 'not found', 'message' => 'Error: short URL not found', 'errorCode' => 404, ); } return yourls_apply_filter( 'api_expand', $return, $shorturl ); }