Hallo,
Ik kom er niet meer uit. Ik ben bezig met een RSS pagina voor mijn weblog en zoek nu hulp. Dit is het eerste systeem dat ik gevonden heb wat geen foutmelding geeft maar een echte RSS weergave toont. Het enige nadeel is dat er geen artikels worden weergegeven. Wie kan mij hier mee helpen? (Eventueel gaat dit kosten?) Het systeem hier onder:
PHP Code:
<?php
// basic server reconciliation
ob_start();
?>
<?php
// tells the server that our document output is in RSS/XML format
header("Content-Type: application/rss+xml; utf-8");
?>
<?php
// declares our XML document and RSS version
echo '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>';
// add a line break for better code structure
echo"\r\n";
?>
<?php
// title of your feed
echo '<title>domain.tld News and Updates</title>';
echo"\r\n";
// link to your site or blo
echo '<link>http://www.domain.tld/</link>';
echo"\r\n";
// description of your feed
echo '<description>The latest technology news and updates domain.tld.</description>';
echo"\r\n";
// language structure of feed
echo '<language>en-us</language>';
echo"\r\n";
// date at which the feed was fully published
echo '<pubDate>Thu, 22 Mar 2012 15:30:00 GMT</pubDate>';
echo"\r\n";
// last date in which the feed was updated
echo '<lastBuildDate>Thu, 22 Mar 2012 15:30:00 GMT</lastBuildDate>';
echo"\r\n";
// official RSS documentation (important)
echo '<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
echo"\r\n";
// link at which the feed was generated (optional)
echo '<generator>yourdomain.tld</generator>';
echo"\r\n";
// email and full name of support team in case or server errors.
echo '<managingEditor>support@yourdomain.tld (Jain Doe)</managingEditor>';
echo"\r\n";
// email and full name of webmaster in case or server errors.
echo '<webMaster>webmaster@yourdomain.tld (John Doe)</webMaster>';
echo"\r\n";
// link to your feed url (important)
echo '<atom:link href="http://yourdomain.tld/yourfeed" rel="self" type="application/rss+xml" />';
echo"\r\n";
?>
<?php
// this function allows to limit the amount of words we will be outputting from our description (optional)
function limit_words($string, $word_limit)
{
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit));
}
// connect to our database
$dbhost="localhost"; // server host
$dbname="dbname"; // database name
$dbuser="siteu"; // database username
$dbpasswd="ww"; // database password
// connect to the db
$link = mysql_connect($dbhost, $dbuser, $dbpasswd);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die ('Can\'t use dbreviews : ' . mysql_error());
}
// Get all articles
$blog_data = mysql_query("SELECT * FROM content"); // change "articles" to your table name and either remove or change "LIMIT 10" to limit the number of entries
// loop through each entry
while ($article = mysql_fetch_array($blog_data))
{
// this will get the date of our article in RSS format
$rij = mysql_fetch_array($blog_data);
$titel = $rij['titel'];
$beschrijving = $rij['beschrijving'];
$datum = $rij['datum'];
// article description
$beschrijving = getVar(str_replace("<br />","",limit_words($article['beschrijving'],35)));
//strip all tags to avoid errors
$beschrijving = strip_tags(getVar(str_replace("<br />","",limit_words($article['beschrijving'],35))));
?>
<!-- Insert information into RSS Feed Format -->
<item>
<title><?php echo $article['titel']; ?></title>
<link>http://appspyre.com/blog/articles/<?php echo str_replace(" ","_",$article['titel']); ?></link>
<guid>http://appspyre.com/blog/articles/<?php echo str_replace(" ","_",$article['titel']); ?></guid>
<pubDate><?php echo $datum; ?></pubDate>
<description><?php echo $beschrijving; ?></description>
</item>
<?php }
?>
- Maak RSS feed met PHP
-
04-08-2012, 11:25 #1
- Berichten
- 940
- Lid sinds
- 16 Jaar
Maak RSS feed met PHP
-
-
04-08-2012, 15:32 #2
- Berichten
- 158
- Lid sinds
- 14 Jaar
Re: Maak RSS feed met PHP
wat bedoel je met "er worden geen artikels weergegeven"? geeft hij wel de titel, maar niet de inhoud van het artikel, of geeft hij helemaal niets?
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic