-
-
Save mach3/d98215a9cae6ef22e741 to your computer and use it in GitHub Desktop.
expand url using goo.gl shortener api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expandGoogleUrl = function( url, key, callback ){ | |
$.ajax({ | |
url : "https://www.googleapis.com/urlshortener/v1/url", | |
dataType : "jsonp", | |
data : { shortUrl : url, key : key }, | |
success : function( data ){ | |
callback( data.error ? false : data.longUrl ); | |
} | |
}); | |
}; | |
// example | |
expandGoogleUrl ( | |
"http://goo.gl/fbsS", | |
"[your api key]", | |
function( url ){ | |
console.log( url ); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment