We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Tweet This

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

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
       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

Eric, if you’re interested in rolling any of my changes into the ‘official’ release, let me know and I’ll send you my version.

       
jasonjulien's avatar
jasonjulien
19 posts
15 years ago
jasonjulien's avatar jasonjulien

Ryan, I’d love to get my hands on your version. Any chance you’d share it?

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

Well, this is Eric’s add-on, so I’d like to get his input as far as releasing it in the wild. We could either roll my updates back into his main release, or I could release a parallel one. Eric…thoughts?

       
Hop Studios's avatar
Hop Studios
459 posts
15 years ago
Hop Studios's avatar Hop Studios

Please let us know what’s going to happen to this code… I’d love to use it with Masuga’s changes.

TTFN Travis

       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
15 years ago
Sean C. Smith's avatar Sean C. Smith

Another vote for Ryan’s changes.

also for some reason when I add this code to my template nothing is output.

{exp:tweet_this title="{title}" url="{title_permalink=blog/single}"}
       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

I have the feeling suzkaw has been unsubscribed from this thread, and isn’t aware of all these requests.

       
Eric Barnes's avatar
Eric Barnes
487 posts
15 years ago
Eric Barnes's avatar Eric Barnes

Yes I went away on vacation and for some reason didn’t get the replies. I will happily add the changes in or let you re-release it. 😊 It was just something simple I needed for a project and figured others might find it useful.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

I updated it pretty extensively and can put it on GitHub (under new name) so others can run with it and make it better.

       
Eric Barnes's avatar
Eric Barnes
487 posts
15 years ago
Eric Barnes's avatar Eric Barnes

Sounds great with me. Just shoot me a link and I will update my post.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

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!

       
Eric Barnes's avatar
Eric Barnes
487 posts
15 years ago
Eric Barnes's avatar Eric Barnes

Thanks for sharing. I just updated the post here and also my blog post with the link to that.

       
Todd D.'s avatar
Todd D.
460 posts
15 years ago
Todd D.'s avatar Todd D.
I put up a repo on GitHub: Short’n Tweet…

Love the name!

       
Marc Tiedemann's avatar
Marc Tiedemann
119 posts
15 years ago
Marc Tiedemann's avatar Marc Tiedemann

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?

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

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.

       
1 2 3 4 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.