Nirav Modh
Nirav Modh

Reputation: 787

How to tweet an url as tiny url like bt.ly?

I have successfully integrated twitter's Oauth into my app, but anybody have an idea how to tweet an url as tiny url like bt.ly?

Upvotes: 1

Views: 1077

Answers (2)

Jon Nylander
Jon Nylander

Reputation: 8963

I would focus on choosing one or a few URL shortener APIs and simply implement them. You can scrape your tweets for URLs and send them to the bit.ly API or the goo.gl API for shortening them.

If you have an API key with bit.ly (which you simply apply for) - you can simply call an URL and get a shortened result, such as:

http://api.bitly.com/v3/shorten?login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&longUrl=http%3A%2F%2Fbetaworks.com%2F&format=json

which would return:

{
    "status_code": 200, 
    "data": {
        "url": "http://bit.ly/cmeH01", 
        "hash": "cmeH01", 
        "global_hash": "1YKMfY", 
        "long_url": "http://betaworks.com/", 
        "new_hash": 0
    }, 
    "status_txt": "OK"
}

the `hash´ part is the what you put after bit.ly. So your shortened link would be: http://bit.ly/cmeH01

Other url shortener services have similar APIs.

Upvotes: 0

Tim Büthe
Tim Büthe

Reputation: 63734

Maybe BitlyAndroid? However, the term is "link shortener", so maybe a search for link shortener android api might help.

Upvotes: 1

Related Questions