<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Examples</title><link>https://sourceforge.net/p/bitly4j/wiki/Examples/</link><description>Recent changes to Examples</description><atom:link href="https://sourceforge.net/p/bitly4j/wiki/Examples/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 11 May 2012 21:42:15 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/bitly4j/wiki/Examples/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Examples modified by adrian</title><link>https://sourceforge.net/p/bitly4j/wiki/Examples/</link><description>
Here you can find some examples on how to use bitly4j:

First of all you'll need to gather from http://bitly.com/a/account#oauthapps client_id and client_secret.

After having both client_id and client_secret, you just need to code in following ways.

1.- Authorize
First operation that you'll need to execute, as you'll need to obtain your apiKey and login from bit.ly using this method.

Bitly4j impl= new Bitly4jImpl();
AuthResponse res = impl.getAuthToken(client_id, client_secret, code, url_call_back);

2.- Shorten
Assuming http://bit.ly is the url we want to shorten:

Bitly4j impl= new Bitly4jImpl();
ShortenResponse resl = impl.shortenUrl(apiKey, login, "http://bit.ly");

3.- Expand
Assuming GGr90x is the hash for http://bit.ly shortenned url, we can get expanded url by coding:

Bitly4j impl= new Bitly4jImpl();
String [] urls={"http://bit.ly/GGr90x"};
ExpandResponse resl = impl.expand(apiKey, login, urls, null);

Or by using an array of hashes:

Bitly4j impl= new Bitly4jImpl();
String [] hashes={"GGr90x"};
ExpandResponse resl = impl.expand(apiKey, login, null, hashes);

4.- InfoUrl

Bitly4j impl= new Bitly4jImpl();
InfoResponse resl = impl.infoUrl(apiKey, login, shortUrl);
			 


Objects AuthResponse, ShortenResponse, ExpandResponse, InfoResponse are defined on javadoc that you can download.
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">adrian</dc:creator><pubDate>Fri, 11 May 2012 21:42:15 -0000</pubDate><guid>https://sourceforge.net7125054ef0fefc10bee4aebbae010f5308dea7a1</guid></item></channel></rss>