[RSS+PHP(?)]RSS Feed in Signature Image...


MS-DOS 2.0
Political User
I have an RSS feed for my blog, and I was wondering if there's a script out there to feed RSS into a signature image?

Just like NetRyder's signature here:

I know it exists, but don't know where to find it!

I was initially using the FeedBurner headline animator which is really easy to setup and use.

The new set that you see, I coded from scratch, mainly as a learning experience. Plus I could customize it the way I wanted. If you've used the GD library before with PHP, it shouldn't be that hard to do. Parse the XML file to pull out only the post titles and stick them onto the image using imagettftext()

I'm sure there are ready scripts somewhere out there, but I'd suggest trying it on your own first. It's more fun that way. Look up some GD tutorials for reference. I can also help you along the way if you need anything. :)


OSNN Veteran Addict
I think I did one for here which used the PHP4 SAX extension to get the RSS data and then GD to overlay text on an image. ElectronicPunk should have it around here somewhere I think


MS-DOS 2.0
Political User
I will first admit that I'm new at PHP, but I'm slowly working my way through it. My first experience with it, so far, has been implementing existing PHP-based pages, like web forums and blogs. But I know it isn't something that's too difficult to figure out, as I've done other programming in the past.

Well, it looks like the GD library is really not that difficult, so that's a good first step. I guess where I need help now is in parsing the RSS feed, so it can be used for imagettftext(). Also, if possible, is there a function that allows you to hyperlink the headlines? That would be great, if possible.

Thanks for your help...



MS-DOS 2.0
Political User

Alright...here's my code:


class RSSParser {

	var $insideitem = false;
	var $tag = "";
	var $title = "";
	var $link = "";

	function startElement($parser, $tagName, $attrs) {
		if ($this->insideitem) {
			$this->tag = $tagName;
		} elseif ($tagName == "ITEM") {
			$this->insideitem = true;

	function endElement($parser, $tagName) {
		if ($tagName == "ITEM") {
			printf("<dt><b><a href='%s'>%s</a></b></dt>",
			$this->title = "";
			$this->link = "";
			$this->insideitem = false;

	function characterData($parser, $data) {
		if ($this->insideitem) {
		switch ($this->tag) {
			case "TITLE":
			$this->title .= $data;
			case "LINK":
			$this->link .= $data;

$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://www.xeidon.org/feed/rss2/","r")
	or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
	xml_parse($xml_parser, $data, feof($fp))
		or die(sprintf("XML error: %s at line %d", 

What I want to do is fix it so I only have the last four headlines. Anyone have any ideas? As it stands, it parses everything in the feed. After I get this part figured out, I'm going to work on applying it to GC library.

Also, if you click on the first link, things like periods and quotation marks turn into unsightly "?"s, even though the RSS feed does not do that. Have any suggestions on how the page should be character encoded (e.g., Unicode UTF-8, etc.)?



MS-DOS 2.0
Political User
I feel like an idiot right now. For the life of me, I can't figure out where to put the "looping" statement to make it work. All I get are errors.

Any help? :p



MS-DOS 2.0
Political User
Nevermind. I started to wonder if, in Wordpress, there was a way to limit how many articles it syndicates to RSS. And there is! I have it now set to 5 (I changed my mind on 4). Thus, I don't need to worry about looping statements.

Thanks for your help on all this.



OSNN Veteran Addict
This is the code that I did for the OSNN Latest News banner/sigs

it fetches the information from the RSS feed and parses it, the charData function is the place where it only gets x number of entries

If I get some time, I might polish this code up a bit

* OSNN VirtuaNews RDF Parser
* Author: StealthNinja
* eMail: coder@stealth-ninja.co.uk
* Written for: ElectronicPunk
* Description:
*  Reads the OSNN RDF backend
*  and then parses that file to
*  obtain the current headlines
*  for inclusion into an image

// variable definitions
// Image Vars
$image = "banner_468x60_var1_back.jpg";        // image dimensions 468x60px
$font  = "verdana.ttf";
$size  = 7;
$horiz = 185;
$vert  = 16;
$maxlen= 60;

// RDF Parsing Vars
$url   = "http://www.osnn.net/modules.php?modname=backend&action=rdf";
$temp  = "temp.xml";
$store = 0;
$count = 0;
$maxent= 4;
$array = array();

// XML parsing functions
function openTag($parser, $name, $attrs) {
    global $store;
    if ($name == "TITLE") {
        $store = 1;
    } else {
        $store = 0;

function closeTag($parser, $name) {
    // w00p de doo

function charData($parser, $data) {
    global $store, $array;

    if ($store == 1 && $count <= $maxent) {
        $array[] = $data;
        $store = 0;

function storeXML($filename, $string) {
    $string = ereg_replace('&amp;', 'and', $string);
    $string = ereg_replace('&', 'and', $string);
    $fp = fopen($filename, "w") or die ("unable to open storage file for writing<br />\nif it exists then chmod {$filename} to 666");
    $write = fwrite($fp, $string);
    return $write;

// define the parser
$parser = xml_parser_create();
xml_set_element_handler($parser, "openTag", "closeTag");
xml_set_character_data_handler($parser, "charData");

if (!(storeXML($temp, file_get_contents($url)))) {
    die ("Unable to store OSNN RDF Data");
if (!($handle = fopen($temp, "r"))) {
    die ("Unable to open Temp store<br />\nif it exists then chmod {$temp} to 666");

while ($data = fread($handle, filesize($temp))) {
    if (!xml_parse($parser, $data, feof($handle))) {
        die (xml_error_string(xml_get_error_code($parser)));


// make sure no strings are too long
foreach ($array as $key => $value) {
    if (strlen($value) > $maxlen) {
        $array[$key] = substr($value, 0, 45) . "..";


// Image Creation
$imgData = getimagesize($image);
if ($imgData[2] == 1) {
    header("Content-type: image/gif");
    $im = ImageCreateFromGIF($image);
} else {
    header("Content-type: image/jpeg");
    $im = ImageCreateFromJPEG($image);

$textc = ImageColorAllocate($im,64,89,132);
$black = ImageColorAllocate($im,0,0,0);


if ($imgData[2] == 1) {
} else {



MS-DOS 2.0
Political User
Ahh...great! Much better than my last code and very easy to customize.

My new signature is now a product of that code, plus a few customizations I made, as a result. Much thanks!

Hello guys! :)

I've been trying to make a sig like this but without success. I have tried your code Geffy but the image does not display (red cross in Internet Explorer).

Anybody know what I'm doing wrong?


hmm I tried a dynamic signature tutorial thingy and did everything by the book and again I run into the same problem!

IE shows red cross, Firefox tells me:
The image "http://www.a-base.dds.nl/sigtest/sample_signature.png" cannot be displayed, because it contains errors.

It makes me think it doesn't parse it correctly as an image or something, I can't include a .htaccess file because my provider doesn't support those, any idea what to do?

hey I can get the .png (second) sig to work just by renaming it to .php so that it is parsed correctly:
Does this mean that my problem with the first sig is some totally different problem as the file allready has the .php extension?
Last edited:


OSNN Veteran Addict
can you make copies of the two php files and give them the extension .phps so that we can look at the php source code. It would be easier to trace the problem that way.
I added this to report error's:

This showed me error's on $count and $maxent

then I changed this:

function charData($parser, $data) {
global $store, $array;

into this:

function charData($parser, $data) {
global $store, $array, $count, $maxent;

and those error's disappeared, but still no luck:crosseyed:

http://www.a-base.dds.nl/sig_rss/rss_image_b.txt <-code

I think the problem is with my host because I tested the standard example code the PHP manual gives for the imagettftext function and that gives me the same error!
http://www.a-base.dds.nl/sig_rss/test.txt <-code

I emailed my host about this, I'll keep you all informed :)
Last edited:
I've narrowed the problem down to the imagettftext thing, seems my host's server doesn't understand it, haven't heard anything from my host yet though...

I got this thing to work with the imagestring function in the meantime :)

How would one go to get the links in there aswell?

http://www.a-base.dds.nl/sig_rss/rss_image_d.txt <-code

Hey this imagestring ain't half bad after a bit of cosmetics:


whoohoo :D

Now how to get description in there? ah well, I'm pretty happy so far ;)
Last edited:
That's odd, I found out my image doesn't totally load on Internet Explorer, on Firefox no probs, I know IE sucks and nobody should use it but what the heck could be causing this because the other sigs I see on this page load normally :crosseyed:


OSNN Veteran Addict
it should work in IE, make sure you completely refresh your cache.

the imagettftext thing would probably be caused by your host not having FreeType2 support in the GD extension for PHP.

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member