• 0

RSS Feed Based Signature


Question

At the moment, in my signature I have the news from my blog, powered by Feedburner. I like how it works, but I think it is a bit too ugly and cumbersome to look nice in a signature. So, I've had an idea that someone might be able to do for me, or even make a site that will do it automatically:

So my feed URL is:

http://www.tim-rogers.co.uk/cutenews/rss.php

and I want to create a signature that shows the title of the latest post made on the blog. If the title is over a certain chracter limit, the ending wil be cut off and replaced with "..."

Here is the template I have created

trbfeedsigsample2tq.png

Can anyone do this?

Link to comment
https://www.neowin.net/forum/topic/348102-rss-feed-based-signature/
Share on other sites

18 answers to this question

Recommended Posts

  • 0

So you just want the one title, no animation?

If you have GD installed on your server, its relatively easy.

(I will write something that should work in PHP for you and reply. - I can do it faster in ASP.net and some other languages but it looks like your running PHP).

I haven't written PHP for a while and don't have it installed, so it MAY work, but i'm pretty sure that i can get something thats close to working at least, or gives the general idea of how you'd do it.

  • 0

Yah, im in the middle of writing it. I can't test it though, because i don't have PHP installed.

To test for gd i think you just have to make a new page with this:

<?php
php_info():
?>

It should list gd somewhere on it "i think there is a section where it lists php component configurations"

  • 0

Heres how you get the title from your feed: (you can also use xml functions for this)

$feedurl = "http://www.tim-rogers.co.uk/cutenews/rss.php"; //can also be local url
$fp = fopen(,"r"); //open the feed
$contents = fread($fp,filesize($feedurl));
fclose($fp);

preg_match("<item>\s*<title>\s*(.*?)\s*</title></item>",$contents,$matchdata); //matches a regular expression for the title
$title = $matchdata[1];

Oh yah, i realized that the code is different for GD2 and plain old GD. So try to find out which one your running.

Also tell me if there are any problems with this code. Try printing $title after it.

  • 0

Well the idea is to take the background image and just throw the text on top.

I can do this for you.

I guess i probably should install php on my computer anyways because its useful and just write the whole thing and attach it, but i would still need to know what version of gd you have.

To find this out:

1. Download attached file

2. Rename it as phpinfo.php

3. Upload it to your server

4. Run it to find out your gd version or send the url to me.

php_info.txt

  • 0

Heres my little script: (also attached as .txt file, rename as .php>

There are a number of variables that are editable, mentioned at the top.

<? 
// editable:
// $feedurl - the url of your feed
// $imageurl - your background image (if not png change imagecreatefrompng to imagecreatefromgif or other types)
// $fontcolor - the font color
// $fontsize - the font size
// $font - the ttf font file path ex: 'arial.ttf'
// $x - the x position of text
// $y - the y position of text
// $angle - text angle

$feedurl = "http://www.tim-rogers.co.uk/cutenews/rss.php";

$fp = fopen($feedurl,"r");
$contents = ".";
while (!feof($fp))
	$contents .= fread($fp,8192);
fclose($fp);

preg_match("#<rss.*?>.*?<channel.*?<item>\s*<title>\s*(.*?)\s*<\/title>#s",$contents,$matchdata);
$title = $matchdata[1];

$imageurl = "http://img348.imageshack.us/img348/7508/trbfeedsigsample2tq.png";

$img = imagecreatefrompng($imageurl);

$font = 'arial.ttf';
$fontcolor = imagecolorallocate($img, 255, 255, 255);
$fontsize = 8;
$x = 65;
$y = 16;
$angle = 0;

imagettftext($img,$fontsize,$angle,$x,$y,$fontcolor,$font,$title);

header('Content-type: image/png');
imagepng($img);
?>

rss.txt

  • 0

Nice job benjeeeboy, can I use it too?

Edit: Can't get it working. :/ Here's my code:

<? 
// editable:
// $feedurl - the url of your feed
// $imageurl - your background image (if not png change imagecreatefrompng to imagecreatefromgif or other types)
// $fontcolor - the font color
// $fontsize - the font size
// $font - the ttf font file path ex: 'arial.ttf'
// $x - the x position of text
// $y - the y position of text
// $angle - text angle

$feedurl = "http://blog.mynimal.net/?feed=rss2";

$fp = fopen($feedurl,"r");
$contents = ".";
while (!feof($fp))
	$contents .= fread($fp,8192);
fclose($fp);

preg_match("#<rss.*?>.*?<channel.*?<item>\s*<title>\s*(.*?)\s*<\/title>#s",$contents,$matchdata);
$title = $matchdata[1];

$imageurl = "http://www.mynimal.net/feed.png";

$img = imagecreatefrompng($imageurl);

$font = 'arial.ttf';
$fontcolor = imagecolorallocate($img, 255, 255, 255);
$fontsize = 8;
$x = 65;
$y = 16;
$angle = 0;

imagettftext($img,$fontsize,$angle,$x,$y,$fontcolor,$font,$title);

header('Content-type: image/png');
imagepng($img);
?>

Using Wordpress, all the files are there. Here's the URL:

http://www.mynimal.net/feed.php

Edited by mynimal
  • 0

I prefer asp.net as a development language. Image output is much easier in it. If you would like, I could work up a signature using that. I do most of my development now on ASP.NET 2.0 but as its still in beta, 1.1 is probably better for something that will be deployed by other people.

I think i'll take a stab at it tommarow.

Edited by benjeeeboy
  • 0

mynimal, feel free to use it.

The reason your feed didn't show was that for whatever reason, your image didn't fit valid php spec (right clicking on it in firefox shows this too under alt).

I opened the image in PS and resaved it and it worked. Try the attached version

post-23893-1122173608.png

  • 0

That looks really good.

I just realized though that if the title in the feed is greater than a certain length (in pixels), it will just run off the edge of the image, while it really should do a ... thing at the end.

I also thought of a few extra options that may be good to add. I will probably post another soon, and asp.net version a little later.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I agree when are you going to read this (really poor BTW) article? Here is a better article so you actually know what is going on and answers questions you had in other comments --> https://arstechnica.com/gadgets/2026/05/speed-boosting-low-latency-profile-is-one-of-the-improvements-coming-to-windows-11/ It is unclear if one will be able to disable the new profile at this point but I am not seeing any reason why one would.
    • I disagree; they come off very "bitchy" and "whiny". Make a great product and combine that with a great price (free) and people will come over to your side. Or build it and they will come as they say. Constantly trying to get attention by complaining all the time, will turn people off to your product.
    • It use to be a nightmare, with LibreOffice supporting a newer draft ODF standard by default, and Microsoft Office supporting the older non-draft standard. Now that they both support the same version of ODF, they should be interoperable.
    • Brave Browser 1.91.171 by Razvan Serea Brave Browser is a lightning-fast, secure web browser that stands out from the competition with its focus on privacy, security, and speed. With features like HTTPS Everywhere and built-in tracker blocking, Brave keeps your online activities safe from prying eyes. Brave is one of the safest browsers on the market today. It blocks third-party data storage. It protects from browser fingerprinting. And it does all this by default. Speed - Brave is built on Chromium, the same technology that powers Google Chrome, and is optimized for speed, providing a fast and responsive browsing experience. Brave Browser also features Brave Rewards, a system that rewards users with Basic Attention Tokens (BAT) for viewing opt-in ads. This innovative system provides an alternative revenue model for content creators and a way to support the Brave community. SlimBrave Neo takes all the good things about Brave and makes them even better by keeping everything clean, light, and privacy-focused. It removes the extra clutter, turns off features you might not need, and cuts down on anything that could slow you down or collect unnecessary data. Because it relies on simple settings and policies instead of modifying the browser itself, you still get full Brave compatibility—just in a smoother, lighter, and more privacy-friendly package. Brave Browser 1.91.171 changelog: General Fixed Cardano not being disabled on upgrade to Brave Origin. Upgraded Chromium to 149.0.7827.103. Origin Removed “Survey Panelist” setting from brave://settings/privacy. Fixed P3A and usage ping under brave://settings/privacy being displayed on first launch on Linux. Upgraded Chromium to 149.0.7827.103. Download: Brave Browser 64-bit | 1.2 MB (Freeware) Download: Brave Browser 32-bit View: Brave Homepage | Offline Installers | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Hi. As the title suggests, I can't access the forum on my phone. I'm using Edge on Android and when I try to navigate to the forum I get a "we value your privacy" popup and none of the buttons are clickable. It effectively stonewalls me from reading any forum content.
  • Recent Achievements

    • Rookie
      Marzoid went up a rank
      Rookie
    • Community Regular
      coch went up a rank
      Community Regular
    • One Year In
      slackerzz earned a badge
      One Year In
    • One Year In
      highriskpaym earned a badge
      One Year In
    • One Month Later
      highriskpaym earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      519
    2. 2
      PsYcHoKiLLa
      190
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      75
  • Tell a friend

    Love Neowin? Tell a friend!