Archive for May, 2009



Wordpress Twitter Hack – How to Make “ReTweet This!” Button using your Favorite URL Shortener!

May 8th, 2009

For those of you who want to create your own “ReTweet This!” button using your favorite URL shortener, (mine is U2S.Me, which I made from scratch) you can easily implement a CURL into your single.php to make this happen on the fly.

Here’s how to do it, add the following code in your single.php (This example uses U2S.Me to shorten URLs, you can easily change the 1st line of the PHP to fit TinyURL API or any other URL shortener you like but yes, do feel free to use mine, as it’s free!)

*Place the code where you want your ReTweet This! button to appear, I’ve placed before my content so Twitters can see it if they come to my site.

<div class=”retweet snap_noshot”>
<?php
$newurl=exec(’curl “http://u2s.me/api.php?url=’.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].’”‘);
$ttitle = get_the_title();
if(strlen($ttitle>110)) {
$ttitle = substr($ttitle, 0,110);
$ttitle .=’…’;
}
$ttitle .=’ ‘;
$turl = ‘http://twitter.com/home?status=’.$ttitle.$newurl;
echo ‘<a target=”_blank” href=”‘.$turl.’”>ReTweet This!</a>’;
?>
</div>

Now, this will basically execute CURL command to get the shortened URL back from U2S.Me, a URL shortening I made couple hours earlier in about couple hours.

You’ve probably noticed other codes that do something like http://myblog.com/p?=112 and this isn’t really great for SEO, shortening your URL first through a URL shortening service lets you preserve your SEO-friendly URL such as http://myblog.com/mycategory/myblogpost.

Here’s a sample Tweet created from the code:

The nuclear doorbell http://u2s.me/vkb1

zedomax

Above is the button generated on Zedomax.com, now you can easily do this too by adding the CSS like this in your style.css file:
.retweet {
float:right;
height:30px;
width:110px;
text-align:center;
margin: 0 0 10px 10px;
padding: 5px 0 0 0;
border:1px solid #0018ff;
background: #0018ff;
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.retweet a {
color:#fff;
text-decoration:none;
}

Please ignore “snap_noshot” tag in my code, that’s if you are using Snap.com to advertise but don’t want Snap to show up on your ReTweet This! button.

I’ve borrowed some code from Drew at Dev-Tips.com, thanks! (He also has an example for a Wordpress plugin using TinyURL, slightly different method than mine but works too.)

Twitter Library Available for Make Controller Hackers!

May 6th, 2009

Make Controller is a 32-bit ATMEGA-based microcontroller you can build cool robots with, someone has created a Twitter library so you can make Twitter apps on the fly, check it out here.

via make

twitter-make-controller