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 * * @param string $shorturl Short URL to check * @return array */ function yourls_api_url_stats( $shorturl ) { $keyword = str_replace( yourls_get_yourls_site() . '/' , '', $shorturl ); // accept either 'http://ozh.in/abc' or 'abc' $keyword = yourls_sanitize_keyword( $keyword ); $return = yourls_get_keyword_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 * * @param string $shorturl Short URL to expand * @return array */ function yourls_api_expand( $shorturl ) { $keyword = str_replace( yourls_get_yourls_site() . '/' , '', $shorturl ); // accept either 'http://ozh.in/abc' or 'abc' $keyword = yourls_sanitize_keyword( $keyword ); $longurl = yourls_get_keyword_longurl( $keyword ); if( $longurl ) { $return = array( 'keyword' => $keyword, 'shorturl' => yourls_link($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 ); }