Documentation

SimplePie
in package

Table of Contents

Properties

$add_attributes  : mixed
$all_discovered_feeds  : mixed
$autodiscovery  : mixed
$autodiscovery_cache_duration  : mixed
$cache  : mixed
$cache_duration  : mixed
$cache_location  : mixed
$cache_name_function  : mixed
$check_modified  : mixed
$config_settings  : mixed
$curl_options  : mixed
$data  : mixed
$enable_exceptions  : mixed
$error  : mixed
$feed_url  : mixed
$file  : mixed
$force_cache_fallback  : mixed
$force_feed  : mixed
$force_fsockopen  : mixed
$image_handler  : mixed
$input_encoding  : mixed
$item_limit  : mixed
$max_checked_feeds  : mixed
$multifeed_objects  : mixed
$multifeed_url  : mixed
$order_by_date  : mixed
$permanent_url  : mixed
$raw_data  : mixed
$registry  : mixed
$sanitize  : mixed
$strip_attributes  : mixed
$strip_htmltags  : mixed
$timeout  : mixed
$useragent  : mixed

Methods

__construct()  : mixed
__destruct()  : mixed
__toString()  : mixed
add_attributes()  : mixed
enable_exceptions()  : mixed
Enable throwing exceptions
error()  : string|array<string|int, mixed>
Get the error message for the occured error
get_author()  : SimplePie_Author|null
Get an author for the feed
get_authors()  : array<string|int, mixed>|null
Get all authors for the feed
get_base()  : string
Get the base URL value from the feed
get_channel_tags()  : array<string|int, mixed>
Get data for an channel-level element
get_description()  : string|null
Get the content for the item
get_feed_tags()  : array<string|int, mixed>
Get data for an feed-level element
get_item()  : SimplePie_Item|null
Get a single item from the feed
get_items()  : array<string|int, SimplePie_Item>|null
Get all items from the feed
get_link()  : string|null
Get a single link for the feed
get_links()  : array<string|int, mixed>|null
Get all links for the feed
get_raw_data()  : string|bool
Get the raw XML
get_type()  : int
Get the type of the feed
init()  : bool
Initialize the feed object
merge_items()  : array<string|int, mixed>
Merge items from several feeds into one
remove_div()  : mixed
sanitize()  : string
Sanitize feed data
set_cache_duration()  : mixed
Set the length of time (in seconds) that the contents of a feed will be cached
set_cache_location()  : mixed
Set the file system location where the cached files should be stored
set_feed_url()  : mixed
Set the URL of the feed you want to parse
set_image_handler()  : mixed
Set the handler to enable the display of cached images.
set_output_encoding()  : mixed
Set the output encoding
set_raw_data()  : mixed
Set the raw XML data to parse
set_url_replacements()  : mixed
Set element/attribute key/value pairs of HTML attributes containing URLs that need to be resolved relative to the feed
sort_items()  : bool
Sorting callback for items
strip_attributes()  : mixed
strip_comments()  : mixed
strip_htmltags()  : mixed
subscribe_url()  : string|null
Get the URL for the feed
store_links()  : mixed
Store PubSubHubbub links as headers

Properties

$add_attributes

public mixed $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'))

$all_discovered_feeds

public mixed $all_discovered_feeds = array()

$autodiscovery

public mixed $autodiscovery = \SIMPLEPIE_LOCATOR_ALL

$autodiscovery_cache_duration

public mixed $autodiscovery_cache_duration = 604800

$cache_duration

public mixed $cache_duration = 3600

$cache_location

public mixed $cache_location = './cache'

$cache_name_function

public mixed $cache_name_function = 'md5'

$check_modified

public mixed $check_modified = \false

$config_settings

public mixed $config_settings = \null

$curl_options

public mixed $curl_options = array()

$enable_exceptions

public mixed $enable_exceptions = \false

$force_cache_fallback

public mixed $force_cache_fallback = \false

$force_feed

public mixed $force_feed = \false

$force_fsockopen

public mixed $force_fsockopen = \false

$image_handler

public mixed $image_handler = ''

$input_encoding

public mixed $input_encoding = \false

$max_checked_feeds

public mixed $max_checked_feeds = 10

$multifeed_objects

public mixed $multifeed_objects = array()

$multifeed_url

public mixed $multifeed_url = array()

$order_by_date

public mixed $order_by_date = \true

$permanent_url

public mixed $permanent_url = \null

$strip_attributes

public mixed $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')

$strip_htmltags

public mixed $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')

$useragent

public mixed $useragent = \SIMPLEPIE_USERAGENT

Methods

add_attributes()

public add_attributes([mixed $attribs = '' ]) : mixed
Parameters
$attribs : mixed = ''

enable_exceptions()

Enable throwing exceptions

public enable_exceptions([bool $enable = true ]) : mixed
Parameters
$enable : bool = true

Should we throw exceptions, or use the old-style error property?

error()

Get the error message for the occured error

public error() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

Error message, or array of messages for multifeeds

get_author()

Get an author for the feed

public get_author([int $key = 0 ]) : SimplePie_Author|null
Parameters
$key : int = 0

The author that you want to return. Remember that arrays begin with 0, not 1

Tags
since
1.1
Return values
SimplePie_Author|null

get_authors()

Get all authors for the feed

public get_authors() : array<string|int, mixed>|null

Uses <atom:author>, <author>, <dc:creator> or <itunes:author>

Tags
since
1.1
Return values
array<string|int, mixed>|null

List of SimplePie_Author objects

get_base()

Get the base URL value from the feed

public get_base([array<string|int, mixed> $element = array() ]) : string

Uses <xml:base> if available, otherwise uses the first link in the feed, or failing that, the URL of the feed itself.

Parameters
$element : array<string|int, mixed> = array()
Tags
see
get_link
see
subscribe_url
Return values
string

get_channel_tags()

Get data for an channel-level element

public get_channel_tags(string $namespace, string $tag) : array<string|int, mixed>

This method allows you to get access to ANY element/attribute in the channel/header section of the feed.

See SimplePie::get_feed_tags() for a description of the return value

Parameters
$namespace : string

The URL of the XML namespace of the elements you're trying to access

$tag : string

Tag name

Tags
since
1.0
see
http://simplepie.org/wiki/faq/supported_xml_namespaces
Return values
array<string|int, mixed>

get_description()

Get the content for the item

public get_description() : string|null

Uses <atom:subtitle>, <atom:tagline>, <description>, <dc:description>, <itunes:summary> or <itunes:subtitle>

Tags
since
1.0

(previously called get_feed_description() since 0.8)

Return values
string|null

get_feed_tags()

Get data for an feed-level element

public get_feed_tags(string $namespace, string $tag) : array<string|int, mixed>

This method allows you to get access to ANY element/attribute that is a sub-element of the opening feed tag.

The return value is an indexed array of elements matching the given namespace and tag name. Each element has attribs, data and child subkeys. For attribs and child, these contain namespace subkeys. attribs then has one level of associative name => value data (where value is a string) after the namespace. child has tag-indexed keys after the namespace, each member of which is an indexed array matching this same format.

For example:

// This is probably a bad example because we already support
//  natively, but it shows you how to parse through
// the nodes.
$group = $item->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group');
$content = $group[0]['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'];
$file = $content[0]['attribs']['']['url'];
echo $file;
Parameters
$namespace : string

The URL of the XML namespace of the elements you're trying to access

$tag : string

Tag name

Tags
since
1.0
see
http://simplepie.org/wiki/faq/supported_xml_namespaces
Return values
array<string|int, mixed>

get_item()

Get a single item from the feed

public get_item([int $key = 0 ]) : SimplePie_Item|null

This is better suited for for() loops, whereas get_items() is better suited for foreach() loops.

Parameters
$key : int = 0

The item that you want to return. Remember that arrays begin with 0, not 1

Tags
see
get_item_quantity()
since

Beta 2

Return values
SimplePie_Item|null

get_items()

Get all items from the feed

public get_items([int $start = 0 ][, int $end = 0 ]) : array<string|int, SimplePie_Item>|null

This is better suited for for() loops, whereas get_items() is better suited for foreach() loops.

Parameters
$start : int = 0

Index to start at

$end : int = 0

Number of items to return. 0 for all items after $start

Tags
see
get_item_quantity
since

Beta 2

Return values
array<string|int, SimplePie_Item>|null

List of SimplePie_Item objects

Get a single link for the feed

public get_link([int $key = 0 ][, string $rel = 'alternate' ]) : string|null
Parameters
$key : int = 0

The link that you want to return. Remember that arrays begin with 0, not 1

$rel : string = 'alternate'

The relationship of the link to return

Tags
since
1.0

(previously called get_feed_link since Preview Release, get_feed_permalink() since 0.8)

Return values
string|null

Link URL

Get all links for the feed

public get_links([string $rel = 'alternate' ]) : array<string|int, mixed>|null

Uses <atom:link> or <link>

Parameters
$rel : string = 'alternate'

The relationship of links to return

Tags
since

Beta 2

Return values
array<string|int, mixed>|null

Links found for the feed (strings)

get_raw_data()

Get the raw XML

public get_raw_data() : string|bool

This is the same as the old $feed->enable_xml_dump(true), but returns the data instead of printing it.

Return values
string|bool

Raw XML data, false if the cache is used

get_type()

Get the type of the feed

public get_type() : int

This returns a SIMPLEPIE_TYPE_* constant, which can be tested against using bitwise operators

Tags
since
0.8

(usage changed to using constants in 1.0)

see
SIMPLEPIE_TYPE_NONE

Unknown.

see
SIMPLEPIE_TYPE_RSS_090

RSS 0.90.

see
SIMPLEPIE_TYPE_RSS_091_NETSCAPE

RSS 0.91 (Netscape).

see
SIMPLEPIE_TYPE_RSS_091_USERLAND

RSS 0.91 (Userland).

see
SIMPLEPIE_TYPE_RSS_091

RSS 0.91.

see
SIMPLEPIE_TYPE_RSS_092

RSS 0.92.

see
SIMPLEPIE_TYPE_RSS_093

RSS 0.93.

see
SIMPLEPIE_TYPE_RSS_094

RSS 0.94.

see
SIMPLEPIE_TYPE_RSS_10

RSS 1.0.

see
SIMPLEPIE_TYPE_RSS_20

RSS 2.0.x.

see
SIMPLEPIE_TYPE_RSS_RDF

RDF-based RSS.

see
SIMPLEPIE_TYPE_RSS_SYNDICATION

Non-RDF-based RSS (truly intended as syndication format).

see
SIMPLEPIE_TYPE_RSS_ALL

Any version of RSS.

see
SIMPLEPIE_TYPE_ATOM_03

Atom 0.3.

see
SIMPLEPIE_TYPE_ATOM_10

Atom 1.0.

see
SIMPLEPIE_TYPE_ATOM_ALL

Any version of Atom.

see
SIMPLEPIE_TYPE_ALL

Any known/supported feed type.

Return values
int

SIMPLEPIE_TYPE_* constant

init()

Initialize the feed object

public init() : bool

This is what makes everything happen. Period. This is where all of the configuration options get processed, feeds are fetched, cached, and parsed, and all of that other good stuff.

Return values
bool

True if successful, false otherwise

merge_items()

Merge items from several feeds into one

public static merge_items(array<string|int, mixed> $urls[, int $start = 0 ][, int $end = 0 ][, int $limit = 0 ]) : array<string|int, mixed>

If you're merging multiple feeds together, they need to all have dates for the items or else SimplePie will refuse to sort them.

Parameters
$urls : array<string|int, mixed>

List of SimplePie feed objects to merge

$start : int = 0

Starting item

$end : int = 0

Number of items to return

$limit : int = 0

Maximum number of items per feed

Tags
link
http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings
Return values
array<string|int, mixed>

remove_div()

public remove_div([mixed $enable = true ]) : mixed
Parameters
$enable : mixed = true

sanitize()

Sanitize feed data

public sanitize(string $data, int $type[, string $base = '' ]) : string
Parameters
$data : string

Data to sanitize

$type : int

One of the SIMPLEPIE_CONSTRUCT_* constants

$base : string = ''

Base URL to resolve URLs against

Tags
access

private

see
SimplePie_Sanitize::sanitize()
Return values
string

Sanitized data

set_cache_duration()

Set the length of time (in seconds) that the contents of a feed will be cached

public set_cache_duration([int $seconds = 3600 ]) : mixed
Parameters
$seconds : int = 3600

The feed content cache duration

set_cache_location()

Set the file system location where the cached files should be stored

public set_cache_location([string $location = './cache' ]) : mixed
Parameters
$location : string = './cache'

The file system location.

set_feed_url()

Set the URL of the feed you want to parse

public set_feed_url(string|array<string|int, mixed> $url) : mixed

This allows you to enter the URL of the feed you want to parse, or the website you want to try to use auto-discovery on. This takes priority over any set raw data.

You can set multiple feeds to mash together by passing an array instead of a string for the $url. Remember that with each additional feed comes additional processing and resources.

Parameters
$url : string|array<string|int, mixed>

This is the URL (or array of URLs) that you want to parse.

Tags
since
1.0

set_image_handler()

Set the handler to enable the display of cached images.

public set_image_handler([str $page = false ][, str $qs = 'i' ]) : mixed
Parameters
$page : str = false

Web-accessible path to the handler_image.php file.

$qs : str = 'i'

The query string that the value should be passed to.

set_output_encoding()

Set the output encoding

public set_output_encoding([string $encoding = 'UTF-8' ]) : mixed
Parameters
$encoding : string = 'UTF-8'

set_raw_data()

Set the raw XML data to parse

public set_raw_data(string $data) : mixed

Allows you to use a string of RSS/Atom data instead of a remote feed.

If you have a feed available as a string in PHP, you can tell SimplePie to parse that data string instead of a remote feed. Any set feed URL takes precedence.

Parameters
$data : string

RSS or Atom data as a string.

Tags
since
1.0

set_url_replacements()

Set element/attribute key/value pairs of HTML attributes containing URLs that need to be resolved relative to the feed

public set_url_replacements([array<string|int, mixed>|null $element_attribute = null ]) : mixed

Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite, |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite, |q|@cite

Parameters
$element_attribute : array<string|int, mixed>|null = null

Element/attribute key/value pairs, null for default

Tags
since
1.0

strip_attributes()

public strip_attributes([mixed $attribs = '' ]) : mixed
Parameters
$attribs : mixed = ''

strip_comments()

public strip_comments([mixed $strip = false ]) : mixed
Parameters
$strip : mixed = false

strip_htmltags()

public strip_htmltags([mixed $tags = '' ][, mixed $encode = null ]) : mixed
Parameters
$tags : mixed = ''
$encode : mixed = null

subscribe_url()

Get the URL for the feed

public subscribe_url([bool $permanent = false ]) : string|null

When the 'permanent' mode is enabled, returns the original feed URL, except in the case of an HTTP 301 Moved Permanently status response, in which case the location of the first redirection is returned.

When the 'permanent' mode is disabled (default), may or may not be different from the URL passed to set_feed_url(), depending on whether auto-discovery was used.

Parameters
$permanent : bool = false

Permanent mode to return only the original URL or the first redirection iff it is a 301 redirection

Tags
since

Preview Release (previously called get_feed_url() since SimplePie 0.8.)

todo

Support itunes:new-feed-url

todo

Also, |atom:link|@rel=self

Return values
string|null

Store PubSubHubbub links as headers

private store_links(SimplePie_File &$file, string $hub, string $self) : mixed

There is no way to find PuSH links in the body of a microformats feed, so they are added to the headers when found, to be used later by get_links.

Parameters
$file : SimplePie_File
$hub : string
$self : string

        
On this page

Search results