• 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

    • So what is it, "Some exciting upgrades happened under the hood, and one of those upgrades is now available to all Windows 11 users." or "Also, you may need to enable it manually, as new features are rolling out gradually. Here is how to do it:" We keep hearing these are rolling out but they never seem to show up, we have force them on with ViVetool. Getting a bit tired of it.
    • Seems very lazy, so basically drain more battery power on laptops/tablets if this is turned on.
    • Edifier's popular R1280Ts bookshelf speaker can be a nice upgrade for your PC desktop audio by Sayan Sen Yesterday we covered a very nice discount on Sony's high-resolution SS-CS5M2 speakers, which are currently on sale for just $178. It packs the rather rare super tweeter that offers an additional level of clarity and "airy"-ness which a tweeter cannot provide. It's a passive speaker though which means it will require external amplification, which will cost extra. Let's say though that you have a budget of under $150 but still want a decent-sounding speaker that's active. The Edifier 1280Ts can help in this regard, as the unit is currently at a decent price of $130 (purchase link under the specs table down below). While you will not get deep sub-bass from the 1280Ts, you should get clearer vocals and highs like cymbals than a cheaper satellite-based 2.1 system. Obviously the soundstage and imaging will also improve due to the better reproduction of highs. As mentioned above, the Edifier R1280Ts is active and so does not need a separate amplifier, as it's a powered system with its own amplification. A great thing about this model is that you can add a separate active subwoofer to it too using the "sub out" option, which essentially acts like an LFE. This way, you can add in the missing deep bass. The technical specifications of the Edifier R1280Ts are given in the table below: Specification Value Total Output Power 42W RMS (21W + 21W) Driver Units 4-inch mid-range/bass driver + 0.5-inch silk diaphragm treble driver Frequency Response 52Hz – 20kHz Signal-to-Noise Ratio (SNR) ≥85dBA Input Sensitivity Line In1: R/L: 500±50mV Line In2: R/L: 700±50mV Inputs Dual RCA inputs Outputs Sub Out port for external subwoofer Get it at the link below: Edifier R1280Ts Powered Bookshelf Speakers - 2.0 Stereo Active Near Field Monitors with Subwoofer Line Out: $129.99 (Sold by Edifier Online Store, Shipped by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. This is a first-party seller link (at the time of article publishing); ensure that you also purchase from a first-party seller link only. If you don't like it or want to look at more options, check out the previous deals that we have covered, OR you can also visit Amazon US deals page. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • Appreciate the focus on UI performance, but this is going the wrong way. Instead of optimizing performance, coding to lower latency, etc. this is just throwing horsepower. This is lazy.
  • Recent Achievements

    • Week One Done
      FBSPL earned a badge
      Week One Done
    • One Year In
      Jim Dugan earned a badge
      One Year In
    • One Month Later
      Tommi118 earned a badge
      One Month Later
    • One Month Later
      sjbousquet earned a badge
      One Month Later
    • Week One Done
      sjbousquet earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      490
    2. 2
      PsYcHoKiLLa
      197
    3. 3
      +Edouard
      155
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      69
  • Tell a friend

    Love Neowin? Tell a friend!