#18 - It is better to shorten URL over SSH since there is the encryption key - futhermore if you run 0bin over SSH.

This commit is contained in:
Rémy HUBSCHER 2013-01-19 18:13:40 +01:00
parent 303905aff5
commit 28bff88784
1 changed files with 13 additions and 3 deletions

View File

@ -178,9 +178,19 @@ window.zerobin = {
/** Get a tinyurl using JSONP */
getTinyURL: function(longURL, success) {
var api = 'http://is.gd/create.php?format=json&url=';
$.getJSON(api + encodeURIComponent(longURL) + '&callback=?', function(data){
success(data.shorturl);
});
$.ajax({
url: 'https://www.googleapis.com/urlshortener/v1/url',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
"longUrl": longURL
}),
processData: false,
dataType: 'json'
}).done(function(data){
console.log(data);
success(data.id);
});
},
/** Check for browser support of the named featured. Store the result