Of course, the client wanted bit.ly instead. Happy to report I just got this working with bit.ly OR is.gd. You need an account and an API key for bit.ly, but it seems to be working OK for me. I switched the “no_short_url” parameter to “short_url”, where you specify one or the other service. If no service is specified, your URL will remain untouched. Sample code:
{exp:tweet_this title="{title}" url="{url_title_path=weblog/item}" short_url="bit.ly"}
<li><a href="http://{twt:twitter_url}{twt:title}">Twitter it up</a></li>
{/exp:tweet_this}
Output to Twitter: My Totally Awesome Article that got truncated right he… h ttp://bit.ly/84gfh (via @masuga)
{exp:tweet_this title="{title}" url="{url_title_path=weblog/item}" short_url="is.gd"}
<li><a href="http://{twt:twitter_url}{twt:title}">Twitter it up</a></li>
{/exp:tweet_this}
Output to Twitter: My Totally Awesome Article that got truncated right he… h ttp://is.gd/hd3e5 (via @masuga)
I made sure to add the “history” to the bit.ly URL so that these API-created links will show in your history there. If you’re interested, the format of the bit.ly link is:
http://api.bit.ly/shorten?version=2.0.1&longUrl=http://site.com&login=mylogin&apiKey=R_apikey0123456789&format=json&history=1
I put up a repo on GitHub: Short’n Tweet There are comments in the plugin about the bit.ly stuff. If anyone wants to fork it, optimize and improve it…have at it!
Whenever I add short_url=”bit.ly” I get the following error message on my template webpage:
Notice: Undefined index: results in /www/htdocs/***/***/plugins/pi.shortn_tweet.php on line 208
Here is the code I used on my template:
{exp:shortn_tweet title="{title}" url="{url_title_path=news/details}" short_url="bit.ly"}
<a href="http://{twt:twitter_url}{twt:title}" class="tweetme">/images/uploads/tt-micro3.png</a>
{/exp:shortn_tweet}
I tried to alter it to:
{exp:shortn_tweet title="{title}" url="{url_title_path=news/details}" short_url="is.gd"}
and it works.
I’m just curious to know why it doesn’t seem to work with “bit.ly” and I’d like to have an alternative on hand.
What am I missing?
Do you have a bit.ly account? You need to have an account and add your username and API key to the plugin for bit.ly links to work correctly (lines 193 and 194).
Wow. Thought I had written this stuff out in the README. Sorry I wasn’t clear about that.
EDIT: Updated the README file at GitHub with info about using bit.ly.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.