Get the Code To Run on Your Own Server
This information is for web site owners that would like to incorporate our Feed2JS technology on their own site- perhaps to customize it, or just to speed up the access if they feel like a local copy is better. Below you can download the necessary script files.
We provide this script as open-source under a GNU General Public License.
To run these scripts, you need a web server capable of running PHP which is rather widely available (and free). You will need to FTP files to your server, perhaps change permissions, and make some basic edits to configure it for your system. I give you the code, getting it to work is on your shoulders. I will try to help, but cannot always promise answers.
- Get the Latest Source Code now available on GitHub
The files provided include:
- feed2js_config.php - local configuration, set the file paths for Magpie, etc.
- feed2js.php - the main workhorse script; see below for configuration details.
- footer - text for footer on Feed2JS web pages
- magpie - latest version of Magpie RSS.
- magpie_debug.php - test script if you have trouble setting up Magpie (best to remove from server if it works OK)
- magpie_simple.php - demo page for magpie
- nosource.php - a simple error file if the script is not provided an URL for the RSS feed.
- preview.php - used to generate previews from the build form.
- styles - sample style sheets used for the preview feature of the build script.
- style_preview.php - generates the styled previews
- style.php - a version of our style tool which will allow your web site users to select and modify CSS styles for their feeds.
- Download and install the Magpie RSS if you need a newer version than the one provided. Place the magpie files inside the directory that contains for feed2js.php scripts:
(main server directory) /feed feed2js.php : : /magpie /extlib Snoopy.class.inc rss_cache.inc rss_fetch.inc rss_parse.inc rss_utils.inc /cache /cache-utf8The "extlib" directory contains the a library file required by magpie "Snoopy.class.inc".
- Inside the magpie directory, are 2 directories named
cache_utf8to store the cache files used by Magpie (the second are for RSS feeds that use UTF8 encoding). Make sure you change the permissions on both of these directories to be world writable (unix commands
chmod 0777 cacheand
chmod 0777 cache_utf8.
- Before going further, you may want to run the magpie test file, magpie_debug.php. If you keep this file in the
/feedand keep the magpie files in its own subdirectory as provided in the download, there should be no edits required to make this work. Loading this in a web browser, e.g.
http://www.mydomain.org/feed/magpie_debug.phpwill test your magpie installation.
See if there are PHP errors-- PHP warnings are not a problem and are ignored by the main script.
- If Magpie works okay, you are ready to configure the feed2js_config.php file. Look for the section labeled "INCLUDES" where you must define the correct paths for the Magpie files, the cache directory, and the time setting for having cache files expire, in seconds. the default is 60*60 or one hour. The default settings will work if you store the magpie files inside the same directory as feed2js.php. This means that you do not have to make any changes to it.
// MAGPIE SETUP ---------------------------------------------------- // Define path to Magpie files and load library // The easiest setup is to put the 4 Magpie include // files in the same directory: // define('MAGPIE_DIR', './magpie/') // Otherwise, provide a full valid file path to the directory // where magpie sites define('MAGPIE_DIR', './magpie/'); // access magpie libraries require_once(MAGPIE_DIR.'rss_fetch.inc'); require_once(MAGPIE_DIR.'rss_utils.inc'); // value of 2 optionally show lots of debugging info, 0 for production define('MAGPIE_DEBUG', 0); // Define cache age in seconds. define('MAGPIE_CACHE_AGE', 60*60);Some Windows servers do not handle the
gmmktimefunction in line 45- this dynamically determines the server time's offset from GMT. If you see errors on this line, you can edit this line to manually set the time zone offset, e.g.:
$tz_offset = -7;
- Run a known RSS Feed through your installed version of the build.php page and then test the style editor page.
src="......"portion, and load it in your web browser. Any PHP errors should appear.
That is all!
The Simplest Installed Directory Structure
Use this outline as a map of the simplest installation, putting all files and Magpie in the same directory. You can create your own intro page (
index.php, index.html) and link to the build and style pages accordingly.
/feed (directory) build.php (feed building tool) feed2js.php feed2js_config.php feed2js_inc.php footer (include file for build.php, style.php) /magpie (directory) /cache (cache directory) /cache_utf8 (cache directory for utf-8 feeds) /ext_lib (directory) Snoopy.class.inc rss_cache.inc rss_fetch.inc rss_parse.inc rss_utils.inc magpie_debug.php magpie_simple.php nosource.php (error page if no RSS provided) popup.js (external library for pop up window openers) preview.php (generates feed preview) /style (directory) (collection of CSS styles) style_preview.php (style preview and editor) style.php (output style tool)