770 |
florian |
1 |
REQUIREMENTS
|
|
|
2 |
|
|
|
3 |
MapieRSS requires a recent PHP 4+ (developed with 4.2.0)
|
|
|
4 |
with xml (expat) support.
|
|
|
5 |
|
|
|
6 |
Optionally:
|
|
|
7 |
* PHP5 with libxml2 support.
|
|
|
8 |
* cURL for SSL support
|
|
|
9 |
* iconv (preferred) or mb_string for expanded character set support
|
|
|
10 |
|
|
|
11 |
QUICK START
|
|
|
12 |
|
|
|
13 |
Magpie consists of 4 files (rss_fetch.inc, rss_parser.inc, rss_cache.inc,
|
|
|
14 |
and rss_utils.inc), and the directory extlib (which contains a modified
|
|
|
15 |
version of the Snoopy HTTP client)
|
|
|
16 |
|
|
|
17 |
Copy these 5 resources to a directory named 'magpierss' in the same
|
|
|
18 |
directory as your PHP script.
|
|
|
19 |
|
|
|
20 |
At the top of your script add the following line:
|
|
|
21 |
|
|
|
22 |
require_once('magpierss/rss_fetch.inc');
|
|
|
23 |
|
|
|
24 |
Now you can use the fetch_rss() method:
|
|
|
25 |
|
|
|
26 |
$rss = fetch_rss($url);
|
|
|
27 |
|
|
|
28 |
Done. That's it. See README for more details on using MagpieRSS.
|
|
|
29 |
|
|
|
30 |
NEXT STEPS
|
|
|
31 |
|
|
|
32 |
Important: you'll probably want to get the cache directory working in
|
|
|
33 |
order to speed up your application, and not abuse the webserver you're
|
|
|
34 |
downloading the RSS from.
|
|
|
35 |
|
|
|
36 |
Optionally you can install MagpieRSS in your PHP include path in order to
|
|
|
37 |
make it available server wide.
|
|
|
38 |
|
|
|
39 |
Lastly you might want to look through the constants in rss_fetch.inc see if
|
|
|
40 |
there is anything you want to override (the defaults are pretty good)
|
|
|
41 |
|
|
|
42 |
For more info, or if you have trouble, see TROUBLESHOOTING
|
|
|
43 |
|
|
|
44 |
SETTING UP CACHING
|
|
|
45 |
|
|
|
46 |
Magpie has built-in transparent caching. With caching Magpie will only
|
|
|
47 |
fetch and parse RSS feeds when there is new content. Without this feature
|
|
|
48 |
your pages will be slow, and the sites serving the RSS feed will be annoyed
|
|
|
49 |
with you.
|
|
|
50 |
|
|
|
51 |
** Simple and Automatic **
|
|
|
52 |
|
|
|
53 |
By default Magpie will try to create a cache directory named 'cache' in the
|
|
|
54 |
same directory as your PHP script.
|
|
|
55 |
|
|
|
56 |
** Creating a Local Cache Directory **
|
|
|
57 |
|
|
|
58 |
Often this will fail, because your webserver doesn't have sufficient
|
|
|
59 |
permissions to create the directory.
|
|
|
60 |
|
|
|
61 |
Exact instructions for how to do this will vary from install to install and
|
|
|
62 |
platform to platform. The steps are:
|
|
|
63 |
|
|
|
64 |
1. Make a directory named 'cache'
|
|
|
65 |
2. Give the web server write access to that directory.
|
|
|
66 |
|
|
|
67 |
An example of how to do this on Debian would be:
|
|
|
68 |
|
|
|
69 |
1. mkdir /path/to/script/cache
|
|
|
70 |
2. chgrp www-data /path/to/script/cache
|
|
|
71 |
3. chmod 775 /path/to/script/cache
|
|
|
72 |
|
|
|
73 |
On other Unixes you'll need to change 'www-data' to what ever user Apache
|
|
|
74 |
runs as. (on MacOS X the user would be 'www')
|
|
|
75 |
|
|
|
76 |
** Cache in /tmp **
|
|
|
77 |
|
|
|
78 |
Sometimes you won't be able to create a local cache directory. Some reasons
|
|
|
79 |
might be:
|
|
|
80 |
|
|
|
81 |
1. No shell account
|
|
|
82 |
2. Insufficient permissions to change ownership of a directory
|
|
|
83 |
3. Webserver runs as 'nobody'
|
|
|
84 |
|
|
|
85 |
In these situations using a cache directory in /tmp can often be a good
|
|
|
86 |
option.
|
|
|
87 |
|
|
|
88 |
The drawback is /tmp is public, so anyone on the box can read the cache
|
|
|
89 |
files. Usually RSS feeds are public information, so you'll have to decide
|
|
|
90 |
how much of an issue that is.
|
|
|
91 |
|
|
|
92 |
To use /tmp as your cache directory you need to add the following line to
|
|
|
93 |
your script:
|
|
|
94 |
|
|
|
95 |
define('MAGPIE_CACHE_DIR', '/tmp/magpie_cache');
|
|
|
96 |
|
|
|
97 |
** Global Cache **
|
|
|
98 |
|
|
|
99 |
If you have several applications using Magpie, you can create a single
|
|
|
100 |
shared cache directory, either using the /tmp cache, or somewhere else on
|
|
|
101 |
the system.
|
|
|
102 |
|
|
|
103 |
The upside is that you'll distribute fetching and parsing feeds across
|
|
|
104 |
several applications.
|
|
|
105 |
|
|
|
106 |
INSTALLING MAGPIE SERVER WIDE
|
|
|
107 |
|
|
|
108 |
Rather then following the Quickstart instructions which requires you to have
|
|
|
109 |
a copy of Magpie per application, alternately you can place it in some
|
|
|
110 |
shared location.
|
|
|
111 |
|
|
|
112 |
** Adding Magpie to Your Include Path **
|
|
|
113 |
|
|
|
114 |
Copy the 5 resources (rss_fetch.inc, rss_parser.inc, rss_cache.inc,
|
|
|
115 |
rss_utils.inc, and extlib) to a directory named 'magpierss' in your include
|
|
|
116 |
path. Now any PHP file on your system can use Magpie with:
|
|
|
117 |
|
|
|
118 |
require_once('magpierss/rss_fetch.inc');
|
|
|
119 |
|
|
|
120 |
Different installs have different include paths, and you'll have to figure
|
|
|
121 |
out what your include_path is.
|
|
|
122 |
|
|
|
123 |
From shell you can try:
|
|
|
124 |
|
|
|
125 |
php -i | grep 'include_path'
|
|
|
126 |
|
|
|
127 |
Alternatley you can create a phpinfo.php file with contains:
|
|
|
128 |
|
|
|
129 |
<?php phpinfo(); ?>
|
|
|
130 |
|
|
|
131 |
Debian's default is:
|
|
|
132 |
|
|
|
133 |
/usr/share/php
|
|
|
134 |
|
|
|
135 |
(though more idealogically pure location would be /usr/local/share/php)
|
|
|
136 |
|
|
|
137 |
Apple's default include path is:
|
|
|
138 |
|
|
|
139 |
/usr/lib/php
|
|
|
140 |
|
|
|
141 |
While the Entropy PHP build seems to use:
|
|
|
142 |
|
|
|
143 |
/usr/local/php/lib/php
|