In my last article we began putting together a solution that will allow us to display dynamic Twitter signature images in forum posts and emails. In this article weíll continue where we left off by adding the functions that will harness the power of GD to create the actual image.
Now that weíve built a class that will produce a Twitter signature image, itís time to put that class to use. The easiest way is to add the relevant code to instantiate this class right into the same PHP file so that the file can be loaded all in one go.
isset($_GET['name']) or die('You must provide a user name.');
new SignatureImage($_GET['name'], 'banners/my_banner.jpg', 'avatars', 'cache');
Adding the above code anywhere outside of the class will do. Save the PHP file with a name such as SignatureImage.php and youíre ready to go. Any time you want to display your signature image, you simply need to add an HTML image reference using the URL to your PHP file. For example, the URL to display my signature image would look something like this:
Donít forget to add the Twitter screen name to the URL so that the PHP script knows what user to get stats for. Since the script returns an actual JPEG image, you can add this quite easily using HTMLís IMG tag or VBCode forum tags.
While we have a fully operational PHP script at this point, letís not stop there. Tune in for the third and final installment in this series and Iíll show you how to implement proper object-oriented PHP error handling into this script. Iíll also show you a quick and effective method of maintaining usage statistics to see how many times your signature image is displayed. Until next time, keep coding!