Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

replaced client side bit.ly with server side bit.ly

  • Loading branch information...
commit 3e67b63c88c64f4e91da3d6d3113ecbf2ce4d23e 1 parent 3b4f0e6
@whoisstan authored
View
1  index.html
@@ -8,7 +8,6 @@
<script src="js/underscore.js" type="text/javascript" charset="utf-8"></script>
<script src="js/backbone.js" type="text/javascript" charset="utf-8"></script>
<script src="js/ICanHaz.min.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=USER_NAME&apiKey=API_KEY"></script>
<!-- CSS -->
<link rel="stylesheet" href="style/bootstrap.css" type="text/css" media="screen" charset="utf-8">
View
19 js/core.js
@@ -18,20 +18,19 @@ var ItemView = Backbone.View.extend({
return "http://chart.apis.google.com/chart?cht=qr&chs="+size+"x"+size+"&chl="+escape(url);
},
render: function(){
- var self=this;
- function callback_name(result)
- {
- var _url=_.pluck(result.results,'shortUrl')[0];
- var shortUrl=self.createQRCodeURL(180,_url);
+ var self=this;
+ $(this.el).html(ich.books(this.model.toJSON()));
+
+ this.request=$.getJSON('php/shorten.php?url='+escape(this.model.get('detail_url')), function(data) {
+ var shortUrl=self.createQRCodeURL(180,data.shortUrl);
$('.qr_code',self.el).append(ich.qr_code({shortUrl:shortUrl}));
$('.details',self.el).append('<div class="list"><b>Download Sizes</b><br/></div>');
_.each([100,200,300,400,500], function(num){
- $('.list',self.el).append(ich.qr_code_downloads({shortUrl:self.createQRCodeURL(num,_.pluck(result.results,'shortUrl')[0]),num:num}));
- });
- }
- BitlyClient.call('shorten',{longUrl: this.model.get('detail_url'),history:1}, callback_name);
- $(this.el).html(ich.books(this.model.toJSON()));
+ $('.list',self.el).append(ich.qr_code_downloads({shortUrl:self.createQRCodeURL(num,data.shortUrl),num:num}));
+ })
+ });
+
return this;
}
});
View
7 php/sampleSettings.php
@@ -1,6 +1,9 @@
<?php
define('AWS_API_KEY', '');
define('AWS_API_SECRET_KEY', '');
-define('AWS_ASSOCIATE_TAG', 'ASSOCIATE TAG');
-define('AWS_ANOTHER_ASSOCIATE_TAG', 'ANOTHER ASSOCIATE TAG');
+
+define('BITLY_USER_NAME','');
+define('BITLY_API_KEY','');
+
+?>
View
1  php/search.php
@@ -4,7 +4,6 @@
defined('AWS_API_KEY') or define('AWS_API_KEY', 'API KEY');
defined('AWS_API_SECRET_KEY') or define('AWS_API_SECRET_KEY', 'SECRET KEY');
-defined('AWS_ASSOCIATE_TAG') or define('AWS_ASSOCIATE_TAG', 'ASSOCIATE TAG');
require '../lib/AmazonECS.class.php';
View
19 php/shorten.php
@@ -0,0 +1,19 @@
+<?php
+
+include 'settings.php';
+
+function make_bitly_url($url,$login,$appkey)
+{
+ //create the URL
+ $bitly = 'http://api.bit.ly/shorten?version='.$version.'&amp;longUrl='.urlencode($url).'&amp;login='.$login.'&amp;apiKey='.$appkey.'&amp;format=json';
+ $response = file_get_contents($bitly);
+
+ $json = @json_decode($response,true);
+ return $json['results'][$url];
+}
+
+echo(json_encode(make_bitly_url($_GET["url"],BITLY_USER_NAME,BITLY_API_KEY,'json')));
+
+?>
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.