mardi 12 juillet 2011

Intégration Bitly Shorten & android App


Bitly is a service among other found on the web to create shortcuts link.

 In my case I use a lot to shorten links to list items from a parsing an RSS feed. character in order to win the gold for sharing these links on twitter.

The integration of this service and guaranteed through a class already developed this need by service team Bitly "Finn J Johnsen Copyright 2010", you will download this class gifts and include the sources of your project .

The source code and available on Googlecode Class (See Link)

Class "BitlyAndroid" provides you with the method "getShortUrl (String urlToShorten)" as the shortcut String return type. Httpclient through.

In just instantiate the class through its constructor with your "API key" and "Login" as parameters for authentication service and the name of the method "getShortUrl"





public String testGetShortUrlAsShouldBeUsed(String urlToShorten) {
  BitlyAndroid bitly = new BitlyAndroid(Util.LOGIN, Util.APIKEY);
  String shortUrl;
  try {
   shortUrl = bitly.getShortUrl(urlToShorten);
   return shortUrl;
  } catch (Exception e) {
   e.printStackTrace();
   return null;
  }
 }





0 commentaires:

Enregistrer un commentaire

Followers

 

Android dev. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com