|
Posted by jon on 01/14/06 03:11
Hello,
I am kind of new to this php programming and after reading the instructions
which came with this rss newsreader program (Magpierss 0.72 ) I am unable to
get it work. If I understand how it suppose to work all what one person has
to do is change the url to a rss feed that you have saved on your site (a
..rss file) and it should displays all the information available from a
parsed feed.
When I try any feed I always get a error. If anyone can explain to me how to
get this to work with a example that really would be appreciated.
thank you
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('MAGPIE_DIR', '../');
define('MAGPIE_DEBUG', 1);
// flush cache quickly for debugging purposes, don't do this on a live site
define('MAGPIE_CACHE_AGE', 10);
require_once(MAGPIE_DIR.'rss_fetch.inc');
if ( isset($_GET['url']) ) {
$url = $_GET['url'];
}
else {
$url = 'http://yourdomain.net/test.rss';
}
test_library_support();
$rss = fetch_rss( $url );
if ($rss) {
echo "<h3>Example Output</h3>";
echo "Channel: " . $rss->channel['title'] . "<p>";
echo "<ul>";
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
echo "<li><a href=$href>$title</a></li>";
}
echo "</ul>";
}
else {
echo "Error: " . magpie_error();
}
?>
<form>
RSS URL: <input type="text" size="30" name="url" value="<?php echo $url
?>"><br />
<input type="submit" value="Parse RSS">
</form>
<h3>Parsed Results (var_dump'ed)</h3>
<pre>
<?php var_dump($rss); ?>
</pre>
<?php
function test_library_support() {
if (!function_exists('xml_parser_create')) {
echo "<b>Error:</b> PHP compiled without XML support (--with-xml),
Mapgie won't work without PHP support for XML.<br />\n";
exit;
}
else {
echo "<b>OK:</b> Found an XML parser. <br />\n";
}
if ( ! function_exists('gzinflate') ) {
echo "<b>Warning:</b> PHP compiled without Zlib support (--with-zlib).
No support for GZIP encoding.<br />\n";
}
else {
echo "<b>OK:</b> Support for GZIP encoding.<br />\n";
}
if ( ! (function_exists('iconv') and
function_exists('mb_convert_encoding') ) ) {
echo "<b>Warning:</b> No support for iconv (--with-iconv) or multi-byte
strings (--enable-mbstring)." .
"No support character set munging.<br />\n";
}
else {
echo "<b>OK:</b> Support for character munging.<br />\n";
}
}
?>
Navigation:
[Reply to this message]
|