Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> [php] Making Feeds Rss
Impious
post Sep 28 2007, 04:52 PM
Post #1


Member - Active Contributor
Group Icon

Group: [HOSTED]
Posts: 78
Joined: 29-June 07
Member No.: 23,027



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

CODE
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>Asta Feeds</title>
<description>Astahost Forum Feeds</description>
<link>http://www.astahost.com/index.php</link>
<language>eng-uk</language>
<item>
<title>Columm Title</title>
<description>Columm Description</description>
<lastBuildDate>Feeds Date</lastBuildDate>
<link>http://www.astahost.com/index.php?action=feeds&id=1>/link>
</item>
</channel>
</rss>


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:
CODE
<?
$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:
CODE
$connect = mysql_connect('localhost','username','password');


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


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


Adding contents to the variable($contents):
CODE
while($creating=mysql_fetch_object($rs_rss))
{
  $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>';
}
[code]

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


Closing the tags
CODE
$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+).

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


Recording into artivles.xml
CODE
fwrite($feedsfile,$xml);


Closing file
CODE
fclose($feedsfile);
?>


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

Yours, Impious
Go to the top of the page
 
+Quote Post
Sten
post Sep 29 2007, 06:28 AM
Post #2


Oh come on Mrs. B!
Group Icon

Group: Members
Posts: 648
Joined: 6-June 07
From: Tasmania, Australia
Member No.: 22,422



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.au/habbo_count_xml.action

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


Go to the top of the page
 
+Quote Post
toby
post Sep 29 2007, 12:27 PM
Post #3


Premium Member
Group Icon

Group: Members
Posts: 488
Joined: 29-September 06
Member No.: 16,228



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Making Educational Game(3)
  2. Making A Turn Based Game Like Ogame(9)
  3. Flash Site Software(11)
  4. Programming In Glut (lesson 4)(7)
  5. Making Xp Look Like Vista(3)
  6. (Nearly) Ultimate Music Posting Guide(11)
  7. Making Xp Starts 60% Faster(3)
  8. Help With Making A Textbased Game(6)
  9. Need Help Making My Ftp Work(14)
  10. [photoshop] Making An Orb(1)
  11. Advice About Making A Text Based Game(9)
  12. Help With Making A Textbased Game(2)
  13. I Really Need Help(5)
  14. Stop anything from making it ur homepage!(52)
  15. My Guide On Runescape Making Millions(4)
  1. Making A Logo In Paint(20)
  2. Need Help In Game Making(3)
  3. Calendar And The Date () Function(0)
  4. Help Me Make A Guide To Website Making!(0)
  5. Want To Make Your Oun PC Games Then Read This(6)
  6. Making Animated Gifs(5)
  7. Making A Value In A Textbox Stay(4)
  8. Making A Link = Mysql_query(8)
  9. Making Something In Mysql Happen Only Once(10)
  10. Making Xubuntu Look Like Windows Vista(6)
  11. Making Fake Virus In Vbs(0)
  12. Animation?(4)
  13. How Can We Make Our On O/s ?(3)
  14. How Can We Make Our On O/s ?(1)
  15. Oh Man, Need Help Making Basic Calc In Console App(5)


 



- Lo-Fi Version Time is now: 7th September 2008 - 01:41 AM