javascript - Why is this Bit.Ly script not working? -
I'm trying to use the bit.ly API to automatically shorten URLs for my blog But this code is not working
& lt; Script & gt; GetShortUrl: function (url, callback) {var url = 'https://api-ssl.bitly.com/v3/shorten?access_token=********************************************************************************** **** & amp; LongUrl = http% 3A% 2F% 2Fwww.techforty.com '; $ .getJSON (url, {}, function (response) {if (callback) callback (response.data.url);}); }, & Lt; / Script & gt;
Is there a quick and easy way to get short URLs from this script in the input box?
It seems that you are using it in an object. Here is the code
var app = {getShortUrl: function (url, callback) {$ .getJSON (url, {}, function (feedback) {if (callback) callback (response);} ); }} App.getShortUrl ('https://api-ssl.bitly.com/v3/shorten?access_token=************************************************************************************** **************************************************************************************************** ************ LongUrl = http: //www.techforty.com ', function (response) {$ (' # result '). Html (response.data.url;)) ;
Comments
Post a Comment