Jump to content

Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (21 April 2014 - 09:11 PM) Hey, Ritesh, Did You Hear Me?
@  yordan : (14 April 2014 - 05:28 PM) By The Way, This Could Be An Interesting Subject For A Topic, What About Posting This Question? Let's See If Other People Have The Same Feeling Concerning Bootlists!
@  yordan : (13 April 2014 - 09:36 AM) Boot Order : Cd, [Usb,] Hard Drive :D
@  yordan : (11 April 2014 - 07:23 PM) I Simply Let The Bios Do That
@  Ritesh : (11 April 2014 - 10:23 AM) Is It Possible To Launch Fedora Live Cd Or Installation Disk From Hard Drive On Windows Platform Using Grub Mbr File.
@  Ritesh : (11 April 2014 - 10:21 AM) No U Are Not.. Btw.. I Have Question For You.
@  yordan : (10 April 2014 - 08:02 AM) You Are Partially Right.
I Was Not.
Nevertheless, I Am Again :)
@  Ritesh : (09 April 2014 - 07:33 PM) :P
@  Ritesh : (09 April 2014 - 07:33 PM) I Think U R Not..
@  yordan : (09 April 2014 - 09:28 AM) I'm The Master Of The Shoutbox!
@  yordan : (05 April 2014 - 10:32 PM) He-He
@  Ritesh : (04 April 2014 - 06:59 PM) Ha Ha Ha ....
@  yordan : (04 April 2014 - 11:15 AM) Welcome Back, Starscream!
@  yordan : (03 April 2014 - 02:31 PM) And I Hope That He Will Come Back Soon :)
@  yordan : (01 April 2014 - 02:53 PM) Nice, Ritesh Came, I'm Not Home Alone Today.
@  Ritesh : (01 April 2014 - 08:51 AM) Oh!!! Poor Dear Yordan..
@  yordan : (31 March 2014 - 10:02 AM) I'm A Poor Lonesome Cow-Boy
@  yordan : (27 March 2014 - 02:22 PM) He Is Unpatient Due To His Patients!
@  Ritesh : (27 March 2014 - 10:46 AM) :(
@  Ritesh : (27 March 2014 - 10:46 AM) He Is Busy With His Patients.

- - - - -

[php] Making Feeds Rss

3 replies to this topic

#1 Impious


    Member - Active Contributor

  • [HOSTED]
  • 78 posts

Posted 28 September 2007 - 04:52 PM

Making feeds RSS with PHP

I'm sorry if someone had already posted about it, but I have made some searches
and did not find anything simmilar.

RSS, very used nowadays by most of sites and it is one of the innovations that
came with the famous Web2.0
For who doesn't know, RSS is a subset of dialects XML that are use to join content or
Web syndication could be acceded by programmes/websites packers.
It is used mainly in sites of news and blogs.
The abbreviation of RSS is used to refer to the following patterns:

- Rich Site Summary (RSS 0.91)
- RDF Site Summary (RSS 0.9 e 1.0)
- Really Simple Syndication (RSS 2.0)

The technology of RSS allows to the users of the internet to enroll in sites that supply
feeds RSS. Those are typically sites that changes or update their content regularly.
For that, they are used Feeds RSS that receive these updatings, of this it sorts out the user
can stay informed of several updatings in several sites without needing to visit them one to one.
The feeds RSS offer content Web or content summaries together with the links for
the complete versions of this content and other data.
This information is given as a file XML called RSS feed, webfeed, Atom or still channel RSS.
An example of as it should follow our RSS

<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<title>Asta Feeds</title>
<description>Astahost Forum Feeds</description>
<title>Columm Title</title>
<description>Columm Description</description>
<lastBuildDate>Feeds Date</lastBuildDate>

Tags above, are pattern Tags that it should be maintained.
Only what will vary inside of the tags above it is TAG <item></item>.
we will create the item tag in the amount of columns or registrations that we will look for in the database.

Now the code php that makes the magic:

Feed RSS:
$rss = '<?xml version="1.0" encoding="iso-8859-1"?>';
$rss .= '<rss version="2.0">';
$rss .= '<channel>';
$rss .= '<title>Asta Feeds</title>';
$rss .= '<description>AstaHost Forum Feeds</description>';
$rss .= '<link>http://www.astahost.com/index.php</link>';
$rss .= '<language>eng-uk</language>';
Database Conection:
$connect = mysql_connect('localhost','username','password');

Selecting Database:
$rs_rss = mysql_query("SELECT id, title,description,date FROM table_colums ORDER BY date DESC LIMIT 20", $connect);

Creating a varible $content NuLL
$content = "";

Adding contents to the variable($contents):
  $content .= '<item>';
  $content .= "<title>$creating->title</title>";
  $content .= "<description>$creating->description</description>";
  $content .= "<lastBuildDate>$creating->date</lastBuildDate>";
  $content .= "<link>http://www.astahost.com/index.php?action=feeds&id=".$creating->id."</link>";
  $content .= '</item>';

[i]Together $rss plus $content to $xml:[/i]
[code]$xml = $rss.$content;

Closing the tags
$xml .= '</channel></rss>';

After we create our rss, we will record it in disk for us to use.

This opens the file for reading and writing; it puts the pointer of the file in the beginning
and it decreases (it truncates) the size of the file for zero.
If the file doesn't exist, try to create it (w+).

$feedsfile = fopen('folder/articles.xml','w+');

Recording into artivles.xml

Closing file

This code searchs on database, returns the last twenty registers and save into .xml document.

Yours, Impious

#2 Sten


    Oh come on Mrs. B!

  • Members
  • 648 posts
  • Gender:Male
  • Location:Tasmania, Australia

Posted 29 September 2007 - 06:28 AM

while your talking about feeds, do you or does anyone else know how to embed just a little thing of how many people are online

the address for the online thing is http://www.habbo.com...ount_xml.action

i just need to know how to embed that, it just shows how many people are on that site.

#3 toby


    Super Member

  • Members
  • 611 posts

Posted 29 September 2007 - 12:27 PM

Similar to his, I want to make a rss feed out of a news page on another site, how would I do this? Something like a socket, loops and arrays, but I'm really not sure.

#4 TavoxPeru


    Super Member

  • [HOSTED]
  • 876 posts
  • Gender:Male
  • Location:Lima - Peru
  • Interests:Web and Software development, Internet, Computers, Electronic music, music, soccer.
  • myCENTs:13.21

Posted 14 October 2008 - 06:52 AM

Thanks a lot for this very useful information, for me, it comes just in time because it is something that i need for a new project.

BTW, i notice that before the code where you close the tags channels and rss there is a typo or it is correct what you post there?

Best regards,

Reply to this topic


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users