Quick Shortener

21.Nov.2019
Quick Shortener This tool allows you to quickly shorten any URL in any page without using any fancy method. This is perhaps the quickest and the easiest method available for you to shorten URLs across all platforms. This method will generate a unique short URL for you that you will be able to access anytime from your dashboard. Use your quick URL below to shorten any URL by adding the URL after /q/?u=. For security reasons, you need to be logged in and using the remember me feature. Check out the examples below to understand how to use this method. https://bitli.li/q/?u=URL_OF_SITE Examples https://bitli.li/q/?u=https://www.google.com https://bitli.li/q/?u=facebook.com https://bitli.li/q/?u=http://www.apple.com/iphone-7/ Grades Please note that this method returns nothing. It simply redirects the user to the redirect page. However, if you need the actual short URL, you can always get it from your dashboard.

Read more

How to use the API

21.Nov.2019
API Usage in PHP An API key is required for requests to be processed by the system. After a user registers, an API key is automatically generated for that user. The API key must be sent with each request via the key parameter (see full example below). If the API key is not sent or expires, there will be an error. Keep the API key a secret to prevent abuse. Submitting a request to shorten a URL To submit a request, the user must use the following format, where api and url variables are required. In the example below, the demo URL is used, but you must use your own domain name. To request a custom alias, just add & custom = at the end. GET https://bitli.li/api/?key=YourAPI&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS Server Response   As before, the response will be encoded in JSON format (default). This is done for ease of use in multiple languages. The first element of the response always tells you whether an error (error: 1) or not (error: 0) occurred. The second element will change relative to the first element. If there is an error, the second element will be named 'msg'. which contains the source of the error, otherwise it will be called "short" which contains the short URL. (See below for an example) No mistakes { "error": 0, "short": "https: \ / \ / bitli.li \ / DkZOb" } an error has occurred   { "error": 1, "msg": "Please enter a valid URL" } Using Plain Text Format You can now request that the answer be in plain text by adding format & format = text at the end of your request. Note that if an error occurs, it will produce nothing; so you can assume that if it is empty there will be an error. Using the API in PHP To use the API in your PHP application, you must submit a GET request via file_get_contents or cURL: both are reliable methods. You can copy the function below. Everything is already set up for you. / **** Sample PHP Function *** / function shorten ($ url, $ custom = "", $ format = "json") { $ api_url = "https://bitli.li/api/?key=5sIVLhTEMTl0 "; $ api_url. = "& url =". urlencode (filter_var ($ url, FILTER_SANITIZE_URL)); if (! empty ($ custom)) { $ api_url. = "& custom =". strip_tags ($ custom); } $ curl = curl_init (); curl_setopt_array ($ curl, array ( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $ api_url )); $ Response = curl_exec ($ curl); curl_close ($ curl); if ($ format == "text") { $ Ar = json_decode ($ Response, TRUE); if ($ Ar ["error"]) { return $ Ar ["msg"]; } else { return $ Ar ["short"];} } ?> Simple use shortened echo ("https://google.com");?> Use with custom alias shortened echo ("https://google.com", "google");?> Use with custom alias and text format shortened echo ("https://google.com", "google", "text");?>

Read more

Top Blog Posts