Skip to content

Instantly share code, notes, and snippets.

@mach3
Created January 12, 2011 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach3/d98215a9cae6ef22e741 to your computer and use it in GitHub Desktop.
Save mach3/d98215a9cae6ef22e741 to your computer and use it in GitHub Desktop.
expand url using goo.gl shortener api
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