// you’re reading...

WordPress Solutions

Getting Twitter Tools to Shorten URLs

I use the Twitter Tools plugin for WordPress to send my new posts to Twitter and to post my tweets on my blog.  Sending your posts to Twitter is a great way to build traffic.

On the first of April, I and others had a problem with the tweets about our blog post not getting shortened URLs.  Someone on Twitter actually noticed and sent me a tweet about it.  I don’t know what changed, but something did.

I never figured out why it stopped working, but I did figure out how to fix it. I am posting that info here so others can use it.   It requires making some php file changes. I am not a php guru so making changes to the php files is always done with care (i.e. backup the file before you change it).

Here is what I did to make it work:

I added the following to the function.php for the template:

1. I added the line below after the first line <?php in function.php

add_filter(‘tweet_blog_post_url’, ‘makeShortURL’);

2. I added the function code  below before the first function definition in the file.

function makeShortURL($URLToConvert) {
$shortURL= file_get_contents(“http://tinyurl.com/api-create.php?url=” . $URLToConvert);
return $shortURL;
}

This worked  for me.  My tweets now show up with a shortend URL using tinyurl.com.  I hope it works for you.

Share and Enjoy:
  • TwitThis
  • Digg
  • del.icio.us
  • Technorati
  • Google Bookmarks
  • StumbleUpon
  • Slashdot

Related posts:

  1. Seven Tools I use with Twitter
  2. Seven things my business is doing with Twitter
  3. Seven useful things you can do with Twitter
  4. Seven thing you can do to get started on Twitter
  5. Best Plug-ins for a WordPress Blog
  6. Its Tweetie for me!
  7. Joy and Despair with Technology

Discussion

2 comments for “Getting Twitter Tools to Shorten URLs”

  1. Hey Dave,
    I tried your example. It didn’t seem to work, I copied and pasted it like you said… it said I had a parse error on line 4, which is this line…

    $shortURL= file_get_contents(”http://tinyurl.com/api-create.php?url=” . $URLToConvert);

    any suggestions?

    Posted by Josh Aronoff | April 21, 2009, 12:08 pm
  2. Here is the code copied from my function.php file.

    function makeShortURL($URLToConvert) {
    $shortURL= file_get_contents(“http://tinyurl.com/api-create.php?url=” . $URLToConvert);
    return $shortURL;
    }

    I don’t see anything wrong with the line you showed. All I can think is to review the code around it.

    David

    Posted by David North | April 21, 2009, 8:57 pm

Post a comment

North Ideas

David NorthI like to solve problems with technology. In this blog, I'd like to share some of my ideas and also tell you about solutions I am currently working on. Welcome, and please share your own ideas with me by leaving a comment.

Tweet this Post

Subcribe to Updates

Loading Quotes...