Xml/Rss feed
Ik heb een script dat een rss feed genereerd voor me site. Het werkt goed en is valid RSS alleen het probleem is: Als ik met de browser Firefox het icoontje voor Rss aanklikt, wil ie hem gaan downloaden. Klein foutje? Misschien, maar geen ramp. Maar hij wil hem gaan downloaden als .php! Ok, de php is al geparsed als ik hem download. Maar toch, is het te verhelpen, want feeds die eindigen op .xml, laat ie gewoon zien in het scherm?
Script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require "settings.php";
connect();
$query = mysql_query("SELECT * FROM `updates` ORDER BY `id` DESC LIMIT 0, 1") or die(mysql_error());
$row = mysql_fetch_assoc($query);
$query = mysql_query('SELECT * FROM `updates` ORDER BY `id` DESC LIMIT 0, 15');
header("Content-type: application/rss+xml");
$content .= '<?xml version="1.0"?>';
$content .= '<rss version="2.0">';
$content .= ' <channel>';
$content .= ' <title>Triads Website</title>';
$content .= ' <link>http://triads.buildtolearn.net</link>';
$content .= ' <description>Hotspot voor games, gezelligheid, scripts, tutorials, en meer...</description>';
$content .= ' <language>nl-nl</language>';
$content .= ' <pubDate>'.get_rfcdate().'</pubDate>';
$content .= ' <lastBuildDate>'.$row['rfcdate'].'</lastBuildDate>';
$content .= ' <docs>http://triads.buildtolearn.net/index.php?page=updates</docs>';
$content .= ' <generator>De webmaster</generator>';
$content .= ' <managingEditor>[email protected]</managingEditor>';
$content .= ' <webMaster>[email protected]</webMaster>';
$content .= ' <copyright>Copyright The Triads Website - Coded en geschreven door Sebazzz - Design door Sebazzz</copyright>';
$content .= ' <ttl>360</ttl>';
while($obj = mysql_fetch_object ($query))
{
$obj->update = htmlentities($obj->update);
$content .= ' <item>';
$content .= ' <title>'.$obj->titel.'</title>';
$content .= ' <link>';
$content .= ' '.$obj->link;
$content .= ' </link>';
$content .= ' <author>[email protected] ('.$obj->auteur.')</author>';
$content .= ' <description>';
$content .= ' '.$obj->update;
$content .= ' </description>';
$content .= ' <pubDate>'.$obj->rfcdate.'</pubDate>';
$content .= ' <guid>';
$content .= ' http://triads.buildtolearn.net/index.php?updates#update'.$obj->id;
$content .= ' </guid>';
$content .= ' <dc:date>'.make_dcdate($obj->datum).'</dc:date>';
$content .= ' </item>';
}
$content .= ' </channel>';
$content .= '</rss>';
print $content;
?>
require "settings.php";
connect();
$query = mysql_query("SELECT * FROM `updates` ORDER BY `id` DESC LIMIT 0, 1") or die(mysql_error());
$row = mysql_fetch_assoc($query);
$query = mysql_query('SELECT * FROM `updates` ORDER BY `id` DESC LIMIT 0, 15');
header("Content-type: application/rss+xml");
$content .= '<?xml version="1.0"?>';
$content .= '<rss version="2.0">';
$content .= ' <channel>';
$content .= ' <title>Triads Website</title>';
$content .= ' <link>http://triads.buildtolearn.net</link>';
$content .= ' <description>Hotspot voor games, gezelligheid, scripts, tutorials, en meer...</description>';
$content .= ' <language>nl-nl</language>';
$content .= ' <pubDate>'.get_rfcdate().'</pubDate>';
$content .= ' <lastBuildDate>'.$row['rfcdate'].'</lastBuildDate>';
$content .= ' <docs>http://triads.buildtolearn.net/index.php?page=updates</docs>';
$content .= ' <generator>De webmaster</generator>';
$content .= ' <managingEditor>[email protected]</managingEditor>';
$content .= ' <webMaster>[email protected]</webMaster>';
$content .= ' <copyright>Copyright The Triads Website - Coded en geschreven door Sebazzz - Design door Sebazzz</copyright>';
$content .= ' <ttl>360</ttl>';
while($obj = mysql_fetch_object ($query))
{
$obj->update = htmlentities($obj->update);
$content .= ' <item>';
$content .= ' <title>'.$obj->titel.'</title>';
$content .= ' <link>';
$content .= ' '.$obj->link;
$content .= ' </link>';
$content .= ' <author>[email protected] ('.$obj->auteur.')</author>';
$content .= ' <description>';
$content .= ' '.$obj->update;
$content .= ' </description>';
$content .= ' <pubDate>'.$obj->rfcdate.'</pubDate>';
$content .= ' <guid>';
$content .= ' http://triads.buildtolearn.net/index.php?updates#update'.$obj->id;
$content .= ' </guid>';
$content .= ' <dc:date>'.make_dcdate($obj->datum).'</dc:date>';
$content .= ' </item>';
}
$content .= ' </channel>';
$content .= '</rss>';
print $content;
?>
Feed adres: http://triads.buildtolearn.net/rss.php
Homepage(voor link naar feed: links): http://triads.buildtolearn.net/
header('Content-Type: text/xml');
Zet deze boven al je output. 't liefst tussen
Gewijzigd op 21/07/2005 22:12:00 door Roy Bongers
Maar op de site van Feedvalidator.org staat dat je application/rss+xml moet gebruiken. Maar hij accepteert het. Thnx again.
http://www.mofert.nl/rss2.php
Ik ben al langer bezig met een RSS feed met PHP, maar het lukt me keer op keer niet. Dit keer heb ich jouw script gekleut, Sebastiaan, maar weer lukt het niet. Probeer `m maar eens te openen op Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
header("Content-Type: text/xml");
$user = "mofert";
$pass = "die_krijgen_jullie_niet";
$host = "localhost";
$dbdb = "mofert_nuuts";
mysql_select_db($dbdb, mysql_connect($host, $user, $pass));
unset($user);
unset($pass);
unset($host);
unset($dbdb);
$query = mysql_query('SELECT * FROM `nuuts` ORDER BY `ts_pub` DESC LIMIT 0, 15');
$content .= '<?xml version="1.0"?>';
$content .= '<rss version="2.0">';
$content .= ' <channel>';
$content .= ' <title>Mofert.nl RSS Feed</title>';
$content .= ' <link>http://www.mofert.nl</link>';
$content .= ' <description>Mofeter nuuts</description>';
$content .= ' <category>local</category>';
$content .= ' <language>li-Moferts</language>';
$content .= ' <docs>http://blogs.law.harvard.edu/tech/rss</docs>';
$content .= ' <managingEditor>[email protected] (Pater)</managingEditor>';
$content .= ' <webMaster>[email protected] (Pater)</webMaster>';
$content .= ' <ttl>15</ttl>';
while($obj = mysql_fetch_object ($query))
{
$obj->titel = htmlentities($obj->titel);
$pupdate = date('r', $obj->ts_pub);
$content .= ' <item>';
$content .= ' <title>'.$obj->titel.'</title>';
$content .= ' <link>';
$content .= ' http://www.mofert.nl/nuutsberich.php?id='.$obj->id;
$content .= ' </link>';
$content .= ' <author>[email protected] (Pater)</author>';
$content .= ' <description>'.$obj->titel.'</description>';
$content .= ' <pubDate>'$pupdate'</pubDate>';
$content .= ' </item>';
}
$content .= ' </channel>';
$content .= '</rss>';
print $content;
?>
header("Content-Type: text/xml");
$user = "mofert";
$pass = "die_krijgen_jullie_niet";
$host = "localhost";
$dbdb = "mofert_nuuts";
mysql_select_db($dbdb, mysql_connect($host, $user, $pass));
unset($user);
unset($pass);
unset($host);
unset($dbdb);
$query = mysql_query('SELECT * FROM `nuuts` ORDER BY `ts_pub` DESC LIMIT 0, 15');
$content .= '<?xml version="1.0"?>';
$content .= '<rss version="2.0">';
$content .= ' <channel>';
$content .= ' <title>Mofert.nl RSS Feed</title>';
$content .= ' <link>http://www.mofert.nl</link>';
$content .= ' <description>Mofeter nuuts</description>';
$content .= ' <category>local</category>';
$content .= ' <language>li-Moferts</language>';
$content .= ' <docs>http://blogs.law.harvard.edu/tech/rss</docs>';
$content .= ' <managingEditor>[email protected] (Pater)</managingEditor>';
$content .= ' <webMaster>[email protected] (Pater)</webMaster>';
$content .= ' <ttl>15</ttl>';
while($obj = mysql_fetch_object ($query))
{
$obj->titel = htmlentities($obj->titel);
$pupdate = date('r', $obj->ts_pub);
$content .= ' <item>';
$content .= ' <title>'.$obj->titel.'</title>';
$content .= ' <link>';
$content .= ' http://www.mofert.nl/nuutsberich.php?id='.$obj->id;
$content .= ' </link>';
$content .= ' <author>[email protected] (Pater)</author>';
$content .= ' <description>'.$obj->titel.'</description>';
$content .= ' <pubDate>'$pupdate'</pubDate>';
$content .= ' </item>';
}
$content .= ' </channel>';
$content .= '</rss>';
print $content;
?>
Quote:
<html><body></body></html>[/QUOTE]
Vervang dit:
Vervang dit:
Quote:
Door dit: Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
<?
mysql_select_db($dbdb, mysql_connect($host, $user, $pass));
unset($user);
unset($pass);
unset($host);
unset($dbdb);
?>
mysql_select_db($dbdb, mysql_connect($host, $user, $pass));
unset($user);
unset($pass);
unset($host);
unset($dbdb);
?>
Quote:
Code (php)
1
2
3
4
2
3
4
<?php
mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($dbdb) or die(mysql_error());
?>
mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($dbdb) or die(mysql_error());
?>
???
Quote:
http://www.mofert.nl/rss2.php.
Ik heb verder nooit problemen gehad met PHP bij mijn host.
Vreeeeeeeeeeeeeemd
Nog steeds geen resultaat, kijk maar op Ik heb verder nooit problemen gehad met PHP bij mijn host.
Vreeeeeeeeeeeeeemd