Pages

Monday, February 21, 2011

Bitly using Mashape

Mashape is an API marketplace where service providers and individual developers can instantly make available an API.Its FREE to use.

Mashape can used in 2 ways

1. Making use of the featured API’s available in Mashape
2. To generate our own API using Mashape.We can upload our API in Mashape & push it into cloud.They are providing the infrastructure for generating the API.

I tried out the first way, which I need currently to work on
Check the featured services provided by Mashape -Explore.
They are in ready to use state.Avaiable in Ruby, Java, Python, PHP Obj-C, and JSON

I tried out with SimpleGeo and Bitly.

Steps to work on Bitly using Mashape :

Step1: SignIn Mashape.Get the API key.It's an automatically generated key which allows you to use the Mashape API from an application. [Ex:API key will be like this APP Key : sgFFDCfgEOKsLMsO9X7l75gCI]


Step2: Download the featured Bitly API from Mashape .
The Jar will contain Bitly component's Java client library will contain the following files:

- mashapeClient.jar - This file to be include in the project, that contains the core
functionalities of every Java client library and that is
immutable for every component.
- Bitly.java - The auto-generated *.java file for the component, that
declares a Bitly class.
- LICENSE - README

Step3 Download the following jars to work on all the above API's using Mashape.

- httpclient-4.0.jar
- httpcore-4.0-beta3.jar
- json-rpc-1.0.jar
- json-20080701.jar

Step4 Signup in Bitly & get the bitly-login and bitly-Api-key.

Step5 Code:

//Enter Mashape API key
Bitly bitly=new Bitly("sgFFDCfgEOKsLMsO9X7l75gCI ");

//Pass the url to be shortened, bitly-login and bitly-Api-key &it returens the JSONObject

JSONObject bitlyResponse = bitly.getShortenedUrl("http://sundarishree.blogspot.com/","shree","R_08de4b3475dd5655818230c15c4966471");


Advantage of this Mashape is no need to download the API jar from different sites. We can get in one point.

1 comment:

  1. Did you know you can shorten your long urls with AdFly and earn dollars from every visitor to your shortened links.

    ReplyDelete