From 28bff88784afacdbe1941627734d221a7aa79486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Sat, 19 Jan 2013 18:13:40 +0100 Subject: [PATCH] #18 - It is better to shorten URL over SSH since there is the encryption key - futhermore if you run 0bin over SSH. --- zerobin/static/js/behavior.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index 89d9770..ee7c2ec 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -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