1 | <?php
|
---|
2 |
|
---|
3 | ini_set('display_errors', 1);
|
---|
4 | ini_set('error_reporting', E_ALL);
|
---|
5 | define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
|
---|
6 | define('MAGPIE_DIR', '../');
|
---|
7 | define('MAGPIE_DEBUG', 1);
|
---|
8 |
|
---|
9 | // flush cache quickly for debugging purposes, don't do this on a live site
|
---|
10 | define('MAGPIE_CACHE_AGE', 10);
|
---|
11 |
|
---|
12 | require_once(MAGPIE_DIR.'rss_fetch.inc');
|
---|
13 |
|
---|
14 |
|
---|
15 | if ( isset($_GET['url']) ) {
|
---|
16 | $url = $_GET['url'];
|
---|
17 | }
|
---|
18 | else {
|
---|
19 | $url = 'http://magpierss.sf.net/test.rss';
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | test_library_support();
|
---|
24 |
|
---|
25 | $rss = fetch_rss( $url );
|
---|
26 |
|
---|
27 | if ($rss) {
|
---|
28 | echo "<h3>Example Output</h3>";
|
---|
29 | echo "Channel: " . $rss->channel['title'] . "<p>";
|
---|
30 | echo "<ul>";
|
---|
31 | foreach ($rss->items as $item) {
|
---|
32 | $href = $item['link'];
|
---|
33 | $title = $item['title'];
|
---|
34 | echo "<li><a href=$href>$title</a></li>";
|
---|
35 | }
|
---|
36 | echo "</ul>";
|
---|
37 | }
|
---|
38 | else {
|
---|
39 | echo "Error: " . magpie_error();
|
---|
40 | }
|
---|
41 | ?>
|
---|
42 |
|
---|
43 | <form>
|
---|
44 | RSS URL: <input type="text" size="30" name="url" value="<?php echo $url ?>"><br />
|
---|
45 | <input type="submit" value="Parse RSS">
|
---|
46 | </form>
|
---|
47 |
|
---|
48 | <h3>Parsed Results (var_dump'ed)</h3>
|
---|
49 | <pre>
|
---|
50 | <?php var_dump($rss); ?>
|
---|
51 | </pre>
|
---|
52 |
|
---|
53 | <?php
|
---|
54 |
|
---|
55 | function test_library_support() {
|
---|
56 | if (!function_exists('xml_parser_create')) {
|
---|
57 | echo "<b>Error:</b> PHP compiled without XML support (--with-xml), Mapgie won't work without PHP support for XML.<br />\n";
|
---|
58 | exit;
|
---|
59 | }
|
---|
60 | else {
|
---|
61 | echo "<b>OK:</b> Found an XML parser. <br />\n";
|
---|
62 | }
|
---|
63 |
|
---|
64 | if ( ! function_exists('gzinflate') ) {
|
---|
65 | echo "<b>Warning:</b> PHP compiled without Zlib support (--with-zlib). No support for GZIP encoding.<br />\n";
|
---|
66 | }
|
---|
67 | else {
|
---|
68 | echo "<b>OK:</b> Support for GZIP encoding.<br />\n";
|
---|
69 | }
|
---|
70 |
|
---|
71 | if ( ! (function_exists('iconv') and function_exists('mb_convert_encoding') ) ) {
|
---|
72 | echo "<b>Warning:</b> No support for iconv (--with-iconv) or multi-byte strings (--enable-mbstring)." .
|
---|
73 | "No support character set munging.<br />\n";
|
---|
74 | }
|
---|
75 | else {
|
---|
76 | echo "<b>OK:</b> Support for character munging.<br />\n";
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | ?>
|
---|