Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Shortened URL with Bitly API and jQuery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.36k
    Comment on it

    Hello Readers,

     

    Bitly API is a way to shrink  long URLs so that we can share it on social media. For example on twitter we can't share long URL so it is a very easy way to shorten long URLs. The most important thing is no server side code required.

     

    To use bit.ly API first of all we need to create an account and logged in on bitly.

     

    To signup / login click here - bitly.com

     

    Here is the example to shrink URLs using bit.ly API:

     

        var bitlyData = {};
        bitlyData['login'] = login;
        bitlyData['apiKey'] = api key;
        bitlyData['longUrl'] = your long url;
        bitlyData['format'] = "json";
        $.ajax({
            url: 'http://api.bitly.com/v3/shorten?',
            data: bitlyData,
            success: function (data){
                console.log(JSON.stringify(data));
            },
            error: function(e) {
                alert("err:"+JSON.stringify(e))
    	}
        });	

     

    In the above example, To  get the values of login, apiKey click here - get your api key and the longUrl is url which you want to shink.

     

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: