Home > Code Snippets > WordTwit – just finished integrating to a couple of my wordpress sites

WordTwit – just finished integrating to a couple of my wordpress sites

I have just finished integrating wordtwit to asianetindia.com as well as this blog. There is nothing much to hoot and howl about it, other than I just made some tweaks here and there. One being the addition of auto hash tagging for twitter with the help of tag the net. And another one to replace the url compression with a similar service which I started just on a fancy, also I replaced those since I was not interested in retaining the included small url options.

While working for the auto hash tagging, I found that the function twit_hit_server, near about line 215, was not updating the $output variable, with the results in case the method was post, so I just added that $output = $snoopy->results; to the conditions inside if ($post) / if ($result).

Then changed

$message = str_replace( '[title]', get_the_title(), $message );

to

$message = str_replace( '[title]', wordtwit_tagify_title(get_the_title()), $message );

inside the function post_now_published definition.

The code listing for wordtwit_tagify_title is

function wordtwit_tagify_title($text){
  
$output '';
  if(
strlen($text) > 110$text substr($text0100) . ' ...';
  
twit_hit_server'http://tagthe.net/api/'''''$outputtrue, array( 'text' => $text'view' => 'json' ) );
  
$res = @json_decode($output);
  if(!isset(
$res->memes[0]->dimensions->topic[0]))
    return 
$text;
  
$topTag $res->memes[0]->dimensions->topic[0];
 
  
$g strpos($text$topTag);
 
  return 
substr($text0$g) . '#' substr($text$g);
  
}

WordTwit is a plugin that utilizes the Twitter API to automatically push a published post to your Twitter account as a tweet. It allows all your Twitter contacts to keep up to date with your blog postings.

Categories: Code Snippets Tags:
  1. No comments yet.
  1. No trackbacks yet.

ninety eight − = ninety