Skip to content


Repository files navigation

Feed2JS Code

by Alan Levine

This directory contains likely the last of Feed2JS source code. It's still running as a free public service at but it barely works and is not maintained.

Most feeds will report error messages about it being invalid, this is the result of the ancient RSS parser not returning results. As of April 22, 2023 I am declaring it dead.

I am sorry but making this code work is beyond my abilities.


This PHP script will take an RSS feed as a value of src="...." and return a JavaScript file that can be linked remotely from any other web page. Output includes site title, link, and description as well as item site, link, and description with these outouts contolled by extra parameters.

It will not run inder PHP 8.


Feed2JS makes use of the Magpie RSS parser from


GNU General Public License Copyright (C) 2004-2013 Alan Levine This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details


Get the Latest Source Code now available at

The files provided include:

  • build.php - build page which will allow your web site users to easily generate their proper JavaScript that works from your installation of Feed2JS.
  • feed2js_config.php - local configuration, set the file paths for Magpie, etc.
  • feed2js.php - the main workhorse script; see below for configuration details.
  • - another version that you can access from the same server using a PHP include method rather than JavaScript.
  • footer - text for footer on Feed2JS web pages
  • magpie (directory) - latest version of MagpieRSS (
  • 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.
  • popup.js - external Javascript library to enable links to appear in JavaScript generated window.
  • preview.php - used to generate previews from the build form.
  • styles (directory) - 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.

Directory structure

(main server directory)



The "extlib" directory contains the a library file required by magpie "".

Inside the magpie directory are 2 directories named cache and cache_utf8 to 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 with unix commands

chmod 0777 cache  
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 /feed2js and 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. will test your magpie installation.

Check 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 directory 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

// 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 gmmktime function 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.

If you are unable to see a feed previewed from the build page, there is likely a syntax error in feed2js.php. To isolate the problem, generate the JavaScript string, copy the URL that appears in the src="......" portion, and load it in your web browser. Any PHP errors should appear.


You probably do not want to run a public service of Feed2JS; you can modify the feed2js_config.php file to include a domain to limit use of feeds (e.g. only sites within that domain can use your install). At this time, it is limited to either a single domain or a wildcard for subdomains (this needs to be updated in the code to allow a list of domains)

The default configuration file does not limit the usage to a domain

// Restrict RSS url to domain
// Example: => allows and
// Example: => allows and

// remove the comment here to activate url restriction
//$restrict_url = "";

// comment out this line to activate url restriction

Modify it to use the domain you want to limit it:

// Restrict RSS url to domain
// Example: => allows and
// Example: => allows and

// remove the comment here to activate url restriction
$restrict_url = "";

// comment out this line to activate url restriction

See also a different approach for limiting via htaccess


Feed to Javascript






No releases published


No packages published