7 The collectData function
LogMANOriginal edited this page 2019-06-27 22:18:22 +02:00

The collectData function is responsible for collecting data and adding items to generate feeds from. If you are unsure how to solve a specific problem, please don't hesitate to open an Issue on GitHub. Existing bridges are also a good source to learn implementing your own bridge.

Implementing the collectData function

Implementation for the collectData function is specific to each bridge. However, there are certain reoccurring elements, described below. RSS-Bridge also provides functions to simplify the process of collecting and parsing HTML data (see "Helper Functions" on the sidebar)

Elements collected by this function must be stored in $this->items. The items variable is an array of item elements, each of which is an associative array that may contain arbitrary keys. RSS-Bridge specifies common keys which are used to generate most common feed formats.

Show example

$item = array(); // Create a new item

$item['title'] = 'Hello World!';

$this->items[] = $item; // Add item to the list


Additional keys may be added for custom APIs (ignored by RSS-Bridge).

Item parameters

The item array should provide as much information as possible for RSS-Bridge to generate feature rich feeds. Find below list of keys supported by RSS-Bridge.

$item['uri']        // URI to reach the subject ("https://...")
$item['title']      // Title of the item
$item['timestamp']  // Timestamp of the item in numeric or text format (compatible for strtotime())
$item['author']     // Name of the author for this item
$item['content']    // Content in HTML format
$item['enclosures'] // Array of URIs to an attachments (pictures, files, etc...)
$item['categories'] // Array of categories / tags / topics
$item['uid']        // A unique ID to identify the current item

All formats support these parameters. The formats Plaintext and JSON also support custom parameters.