Hi,
I'm developing a J2EE website with spring framework. I want my website to share with Twitter but I couldn't succeed using bit.ly API. the function makes bit.ly link but in Twitter's share page I only see the full link. How can I send the bit.ly link to Twitter?
The bit.ly response which I get from firebug:
BitlyCB.getBitlyUrl({"errorCode": 0, "errorMessage": "", "results": {"http://twitter.com/home?status=http://www.google.com": {"userHash": "dodUFu", "hash": "9KnUl2", "shortUrl": "http://bit.ly/dodUFu", "shortCNAMEUrl": "http://bit.ly/dodUFu", "shortKeywordUrl": ""}}, "statusCode": "OK"})
If you try http://bit.ly/dodUFu you can understand me.
My code is below:
<script type="text/javascript" charset="utf-8"
src="http://bit.ly/javascript-api.js?version=latest&amp;login=mylogin&amp;apiKey=mykey"></script>
<a class="_ffShare_"
onclick="onlyShortenUrl('http://twitter.com/home?status=http://mypage');">
<img src="http://yakup-laptop:8080/images/theme/default/twitter.png"></img>
</a>
function onlyShortenUrl(longUrl){
//single shortener
BitlyCB.getBitlyUrl = function(data) {
var shortUrl = extractShortUrl(data);
window.open(shortUrl,'_blank');
return shortUrl;
}
return BitlyClient.call('shorten', {'longUrl': longUrl}, 'BitlyCB.getBitlyUrl');
}
function extractShortUrl(data){
//bitly util method probably not useful standalone
var shortUrl = '';
var first_result;
// Results are keyed by longUrl, so we need to grab the first one.
for (var r in data.results) {
first_result = data.results[r]; break;
}
for (var key in first_result) {
shortUrl = r ;
}
return shortUrl;
}