Main Content

Easy feed!

Archive - Originally posted on "The Horse's Mouth" - 2006-03-21 07:29:37 - Graham Ellis

Want to provide sites that work close along side you with a feed of your blog? In recent versions of PHP, you can include a remote file from their server in your page. Here's a little example that's on our site - we're pulling down a piece of PHP via a URL.

Want the latest news from Well House Consultants? Read
<?php include("http://www.wellho.net/hml.inc"); ?> on
"The Horse's Mouth".


If you've PHP 4.3.0 or later, and allow_url_fopen is allowed, then the above example should work for you and give you a link where the text will change each time I post a new article on "The Horse's Mouth".

Both the site offering a service such as this AND the user site need to be aware of the security implications; our hml.inc file is open to anyone to read (and so must NOT give away secrets like passwords), and the user site must trust their supplier to be competent not to compromise their security. But with closely linked sites, it can work well.

Note - the included file must NOT have a parsed extension such as .php ... otherwise it will be run on the site offering the service rather than being shipped down to the user site..

This is a working example, so you can see the source code through the URL shown above. I've also indexed it and you can see it here in our resource library