Posted By

stephanepericat on 03/07/10


Tagged

mootools JSONP bitly


Versions (?)

Connect to Bit.ly API with MooTools


 / Published in: JavaScript
 

A simple way to send an ajax request to the Bit.ly API and return the shortened url.

  1. /**
  2.  * author : Stephane P. Pericat
  3.  * date : 2010-03-02
  4.  */
  5.  
  6. var link = "http://www.snipplr.com/";
  7. var slink = null;
  8.  
  9. var short = new Request.JSONP({
  10. url: 'http://api.bit.ly/shorten',
  11. callbackKey: 'callback',
  12.  
  13. onSuccess: function (result) {
  14. slink = result['results'][''+link+'']['shortUrl'];
  15. console.log(slink)
  16. },
  17. data: {
  18. version: '2.0.1',
  19. longUrl: link,
  20. login: 'username',
  21. apiKey: 'R_dd761983d39ab216af226a19756496d3',
  22. format: 'json'
  23. }
  24. }).send();

Report this snippet  

You need to login to post a comment.