PHP Classes

File: examples/example.php

Recommend this page to a friend!
  Classes of Stefan Gabos   RSS and Atom Feeds Processing API   examples/example.php   Download  
File: examples/example.php
Role: Example script
Content type: text/plain
Description: EXAMPLE script
Class: RSS and Atom Feeds Processing API
Get RSS and Atom feeds and display using templates
Author: By
Last change:
Date: 16 years ago
Size: 1,751 bytes


Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <meta http-equiv="content-type" content="text/html; charset=windows-1250">
        <meta name="generator" content="PSPad editor,">
        <title>RSS/ATOM Feeds Processing API</title>


    <form method="get">
        Enter a RSS/ATOM feed URL here:
        <input type="text" name="feed" value="<?=isset($_GET["feed"]) ? $_GET["feed"] : ""?>" />
        <input type="submit" value="fetch!" />

        <br />
        for an instant start, try this ones:<br />
        <a href="?feed=">New York Times - Technology</a> |
        <a href="?feed=">BBC - Technology</a> |
        <a href="?feed=">My blog</a> |
        <br /><br />


require "../api.feedsprocessing.php";

// instantiate the API
$feed = new feedsProcessingAPI();

// timeout after trying to fetch a feed for longer than 10 seconds
$feed->timeout = 10;

// if anything submitted
if (isset($_GET["feed"])) {

// fetch the feed
if ($feed->get($_GET["feed"])) {

// output using default template (and only show the latest 5)
                // and display a message in case of error

            } else {

print_r("Error: " . $feed->error . " (see the manual about what each error number means)");