• Up until April Fool’s day this plugin has been working perfectly. Each time a new blog post was made it would send to the Twitter account and the URL was made into a tinyURL.

    Now, it won’t tinyURL for some reason. It still posts to Twitter, just no shortening of the URL. Anyone else have this issue or know of a fix? I like the plugin as it is a small foot print and was working perfect until this.

Viewing 15 replies - 1 through 15 (of 15 total)
  • I am having the same problem. Wish someone knew the answer.

    I was reading the documentation (I know that is unusual) for Twitter Tools and it says it does not do any URL shortening, but let Twitter do it. So maybe that function is not working in Twitter any more.

    Twitter tools readme file has info about adding a filter and a function to do the URL shortening.

    It says:

    Twitter Tools also provides a filter on the URL sent to Twitter so that you can run it through an URL-shortening service if you like.

    tweet_blog_post_url

    Your plugin function will receive the URL as the first parameter.

    Example psuedo-code:

    function my_short_url($long_url) { // do something here - return the shortened URL }
    add_filter('tweet_blog_post_url', 'my_short_url')

    I am not sure were to put this code or where to get a urlshortening function. If anyone knows how to do it please post.

    You need to build the integration with the url shortening service you wish to use. Using the filter Twitter Tools provides.

    I was able to get this to work.

    I add the following to the funciton.php for the template.

    add_filter(‘tweet_blog_post_url’, ‘makeShortURL’);

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

    In the function.php

    1. I added the
    add_filter(‘tweet_blog_post_url’, ‘makeShortURL’);

    After the frist line <?php

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

    I tried putting that into my function.php file and it didn’t work. Any other ideas? Any other place I can put it?

    I think it will work there (in the function.php for the active theme)

    check out all the formating of the statements, ending ; all that programing stuff has to be correct or it will not work.

    Sorry, I don’t have any other ideas.

    This code will do the trick for bit.ly short URLs:

    function bitly($longUrl) {
      $bitly = json_decode(file_get_contents('https://api.bit.ly/shorten?version=2.0.1&amp;login=YOUR_LOGIN&amp;apiKey=YOUR_API_KEY&amp;longUrl=' . $longUrl), true);
      return $bitly['results'][$longUrl]['shortUrl'];
    }
    add_filter('tweet_blog_post_url', 'bitly');

    Like the others guys have said, find the functions.php for your WordPress theme (i.e. wp-content/themes/default/functions.php) and place it there.

    Note that you’ll need to sign up for a bit.ly account if you don’t already have one, and replace YOUR_LOGIN and YOUR_API_KEY with your own.

    If this doesn’t work, chances are your PHP installation doesn’t allow file_get_contents() to access URLs.

    No need to modify function.php… Just edit the plugin and replace this line

    $url = apply_filters('tweet_blog_post_url', get_permalink($post_id));

    with this

    $url = apply_filters('tweet_blog_post_url', file_get_contents("https://tinyurl.com/api-create.php?url=" . get_permalink($post_id)));

    It should be modified on the next version of Twitter Tools… By the way, it’s an awesome plugin, I love it ??

    In response to rmckillen’s post re: bit.ly and servers not allowing file_get_contents() I have spent the last few hours coming up with this to get around that.

    Replace
    $url = apply_filters('tweet_blog_post_url', get_permalink($post_id));

    with

    $ch = curl_init("https://api.bit.ly/shorten?format=xml;version=2.0.1&amp;login=USERNAME&amp;apiKey=APIKEY&amp;longUrl=".get_permalink($post_id));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    $xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
    $bitly = $xml->results->nodeKeyVal->shortUrl;
    $url = apply_filters('tweet_blog_post_url', $bitly);

    Hope that helps anyone that needs it.

    Thank you for the solution, Mr Anderson.
    (Why do I feel like I’m in the Matrix?)

    ??

    Worked for me (using Tiny Url of course)

    Tried and tested.

    With the latest version I was having the same problem. Everything worked perfectly, but Twitter-Tools was not posting my links when sending through tags and post titles.

    After some hunting I spotted the function in the main plugin file that posts the updates to Twitter.

    I changed this line from:

    $data = apply_filters(‘aktt_do_tweet_post’, $data, $tweet); // return false here to not make a blog post

    to: (I added the $url part at the end)

    $data = apply_filters(‘aktt_do_tweet_post’, $data, $tweet, $url); // return false here to not make a blog post

    It all seems to be working 100% now finally, yay!

    I just checked the code and I’m afraid I don’t see how passing an additional argument in that spot could possibly affect this.

    jamiedavies, thanks for the code, as I can’t use file_get_contents()

    However, I now get
    Fatal error: Cannot instantiate non-existent class: simplexmlelement

    Can anyone help

    I was hoping upgrading to 2.2.1 was going to fix my issue with this, but still not working!

    I’ve tried with both bit.ly and tinyurl editing both functions.php and twitter-tools.php

    le sigh!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Twitter Tools] URL not made tiny’ is closed to new replies.