I been using twitter for some days now and I got a little addicted to tweet. But you know twitter is one of this things that no one reads or at least no one wants to admit that reads.
So there must be a way for you to force everyone to read your tweets. That’s why they invented the twitter signatures there are a lot of sites that do this for you. Its easy you give your user name and they give you the link to an image that you can put in the signature of your favorite forum.
But lets be honest no one wants to spread someone else site and they intentionally add their url to the image also there are a few designs that everyone use.
That’s why I enter into the web in a quest for the holly script. “The perfect twitter signature script”. I found one but didn’t work with my host. Later I found many ways to collect the info from twitter so I decided to make one for myself and this is the result.
Well its simple I found a nice library that does all the hard work of retrieving messages from twitter : twitter for php 1.0 by David Grudl with this and with a small knowledge of image creating with php I made my twitter signature.
Continue reading to learn how and download the code.
First we need an image that is going to be our template in the zip I added this one.
Base Image
Second the script looks for your latest tweet and print this image.
Image with the tweet.
-”Omg that was way too sexy I want this what do I need ?”
You need a host with php5 with cURL extension.
If you are hosted in dreamhost this works like a charm, im on dreamhost.
-”OK I have all that what else do i need?”
You need to download the zip that you can grab at the end of this article and follow this steps
1)
edit sc-twittsig.php
and put your username and password
2)
upload everything to your ftp
3)
with your favorite browser point to the location of sc-twittsig.php in your website
example:
http://www.silvercrow.org/sc-twittsig/sc-twittersig.php
if everything was ok you should read this:
----------------------------------------------- Starting the script Calling twitter and asking for the info.. Creating your image... Success your new image is done! :D ----------------------------------------------- |
then browse to the same path and look for this file: twittersignature.png
example:
http://www.silvercrow.org/sc-twittsig/twittersignature.png
4) Enjoy go edit my image and make your own signature you can even use another font and colors.
-”Wait a minute this isn’t dynamic I need to browse to sc-twittsig.php everytime I want the image to change to the latest tweet!”
Ok relax this is true you need to execute the code in order to change the image but there is a solution you can set a cron job to do this for you.
here is an example of mine remember im on dreamhost if you are hosted somewhere else contact your hosting provider.
30 * * * * wget -q --delete-after http://silvercrow.org/sc-twittsig/sc-twittsig.php |
That execute my twittsig code every hour at the minute 30.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php //-------------------------------------------------------------- /* Description: This script generates an image of your latest tweet Author: silvercrow Author URI: http://www.silvercrow.org */ //-------------------------------------------------------------- //Generating the code header('Content-type: text/plain'); echo "Starting the script\n"; //Calling the simple twitter function require_once 'twitter.class.php'; //-------------------------------------------------------------- // // ### Twitter user,password ### $twitter = new Twitter('username', 'password'); // withFriends TRUE if you want to display friends messages $withFriends = FALSE; //-------------------------------------------------------------- echo "Calling twitter and asking for the info..\n"; // Collecting some info $channel = $twitter->load($withFriends); // The date format can be changed $dt=date("F j, Y, g:i a", strtotime($channel->status->created_at)); $name=$channel->status->user->name; $tw=$channel->status->text; //-------------------------------------------------------------- echo "Creating your image... \n"; $im = imageCreateFromPng("baseimage.png"); // backgound and text color $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0); //Custom line limit $tw_text = wordwrap($tw,55); // Custom font. $font = './arial.ttf'; // Twitter user name display imagefttext($im, 8, 0, 110, 20, $textcolor, $font, $name.":"); // Twitter message display imagefttext($im, 8, 0, 115, 34, $textcolor, $font, $tw_text, array('linespacing'=>.8)); // Twitter date of message display imagefttext($im, 7, 0, 255, 60, $textcolor, $font, $dt); //-------------------------------------------------------------- // Create twittersignature.png imagepng($im,"twittersignature.png"); // Free up some memory imagedestroy($im); echo "Success your new image is done! :D\n"; //-------------------------------------------------------------- ?> |
Is there anything I can do with the size? What if I wanted to make it taller and skinnier?
April 16th, 2009Yes you can use another image just play with the custom line limit and the displacement of the data (lines in the code 40,42 and 44) so the text gets printed inside the image.
April 17th, 2009where shall i put this code ->
May 10th, 2009wget -q –delete-after http://silvercrow.org/sc-twittsig/sc-twittsig.php
to make it dynamic?
Can you give me a more detailed explanation?
That is a cron job and is done with ssh (secure shell) or in some cases your host has it on the options panel. Ask them about cron jobs and how do you set one.
In my case I use putty to change that options and dreamhost let you have an account for ssh.
Good Luck.
May 11th, 2009To use Cronjob you can find Cronjob services ! I’m German and i Use the free Cronjob service from http://www.cronjob.de . =) So its easy cheesy lol
December 29th, 2009