Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
SimplePie Class Reference

SimplePie. More...

Public Member Functions

 __construct ()
 The SimplePie class contains feed level data and options.
 
 __destruct ()
 Remove items that link back to this before destroying this object.
 
 __call ($method, $args)
 Magic method handler.
 
 __toString ()
 Used for converting object to a string.
 
 add_attributes ($attribs='')
 
 enable_cache ($enable=true)
 Enable/disable caching in SimplePie.
 
 enable_exceptions ($enable=true)
 Enable throwing exceptions.
 
 enable_order_by_date ($enable=true)
 Set whether feed items should be sorted into reverse chronological order.
 
 encode_instead_of_strip ($enable=true)
 
 error ()
 Get the error message for the occurred error.
 
 force_cache_fallback ($enable=false)
 SimplePie to continue to fall back to expired cache, if enabled, when feed is unavailable.
 
 force_feed ($enable=false)
 Force the given data/URL to be treated as a feed.
 
 force_fsockopen ($enable=false)
 Force SimplePie to use fsockopen() instead of cURL.
 
 get_all_discovered_feeds ()
 
 get_author ($key=0)
 Get an author for the feed.
 
 get_authors ()
 Get all authors for the feed.
 
 get_base ($element=array())
 Get the base URL value from the feed.
 
 get_cache_filename ($url)
 Return the filename (i.e.
 
 get_categories ()
 Get all categories for the feed.
 
 get_category ($key=0)
 Get a category for the feed.
 
 get_channel_tags ($namespace, $tag)
 Get data for an channel-level element.
 
 get_contributor ($key=0)
 Get a contributor for the feed.
 
 get_contributors ()
 Get all contributors for the feed.
 
 get_copyright ()
 Get the copyright info for the feed.
 
 get_description ()
 Get the content for the item.
 
 get_encoding ()
 Get the character encoding used for output.
 
 get_favicon ()
 Get the favicon for the current feed.
 
 get_feed_tags ($namespace, $tag)
 Get data for an feed-level element.
 
 get_image_height ()
 Get the feed logo's height.
 
 get_image_link ()
 Get the feed logo's link.
 
 get_image_tags ($namespace, $tag)
 Get data for an channel-level element.
 
 get_image_title ()
 Get the feed logo's title.
 
 get_image_url ()
 Get the feed logo's URL.
 
 get_image_width ()
 Get the feed logo's link.
 
 get_item ($key=0)
 Get a single item from the feed.
 
 get_item_quantity ($max=0)
 Get the number of items in the feed.
 
 get_items ($start=0, $end=0)
 Get all items from the feed.
 
 get_language ()
 Get the language for the feed.
 
 get_latitude ()
 Get the latitude coordinates for the item.
 
 get_link ($key=0, $rel='alternate')
 Get a single link for the feed.
 
 get_links ($rel='alternate')
 Get all links for the feed.
 
 get_longitude ()
 Get the longitude coordinates for the feed.
 
 get_permalink ()
 Get the permalink for the item.
 
 get_raw_data ()
 Get the raw XML.
 
get_registry ()
 Get the class registry.
 
 get_title ()
 Get the title of the feed.
 
 get_type ()
 Get the type of the feed.
 
 handle_content_type ($mime='text/html')
 Send the content-type header with correct encoding.
 
 init ()
 Initialize the feed object.
 
 remove_div ($enable=true)
 
 rename_attributes ($attribs='')
 
 sanitize ($data, $type, $base='')
 Sanitize feed data.
 
 set_author_class ($class='SimplePie_Author')
 Set which class SimplePie uses for handling author data.
 
 set_autodiscovery_cache_duration ($seconds=604800)
 Set the length of time (in seconds) that the autodiscovered feed URL will be cached.
 
 set_autodiscovery_level ($level=SIMPLEPIE_LOCATOR_ALL)
 Set how much feed autodiscovery to do.
 
 set_cache_class ($class='SimplePie_Cache')
 #+ Useful when you are overloading or extending SimplePie's default classes.
 
 set_cache_duration ($seconds=3600)
 Set the length of time (in seconds) that the contents of a feed will be cached.
 
 set_cache_location ($location='./cache')
 Set the file system location where the cached files should be stored.
 
 set_cache_name_function ($function='md5')
 Set callback function to create cache filename with.
 
 set_caption_class ($class='SimplePie_Caption')
 Set which class SimplePie uses for <media:text> captions.
 
 set_category_class ($class='SimplePie_Category')
 Set which class SimplePie uses for handling category data.
 
 set_content_type_sniffer_class ($class='SimplePie_Content_Type_Sniffer')
 Set which class SimplePie uses for content-type sniffing.
 
 set_copyright_class ($class='SimplePie_Copyright')
 Set which class SimplePie uses for <media:copyright>
 
 set_credit_class ($class='SimplePie_Credit')
 Set which class SimplePie uses for <media:credit>
 
 set_curl_options (array $curl_options=array())
 Set custom curl options.
 
 set_enclosure_class ($class='SimplePie_Enclosure')
 Set which class SimplePie uses for feed enclosures.
 
 set_favicon_handler ($page=false, $qs='i')
 Set the favicon handler.
 
 set_feed_url ($url)
 Set the URL of the feed you want to parse.
 
 set_file (&$file)
 Set an instance of {.
 
 set_file_class ($class='SimplePie_File')
 Set which class SimplePie uses for remote file fetching.
 
 set_https_domains ($domains=array())
 Set the list of domains for which to force HTTPS.
 
 set_image_handler ($page=false, $qs='i')
 Set the handler to enable the display of cached images.
 
 set_input_encoding ($encoding=false)
 Set the character encoding used to parse the feed.
 
 set_item_class ($class='SimplePie_Item')
 Set which class SimplePie uses for handling feed items.
 
 set_item_limit ($limit=0)
 Set the limit for items returned per-feed with multifeeds.
 
 set_locator_class ($class='SimplePie_Locator')
 Set which class SimplePie uses for auto-discovery.
 
 set_max_checked_feeds ($max=10)
 Set maximum number of feeds to check with autodiscovery.
 
 set_output_encoding ($encoding='UTF-8')
 Set the output encoding.
 
 set_parser_class ($class='SimplePie_Parser')
 Set which class SimplePie uses for XML parsing.
 
 set_rating_class ($class='SimplePie_Rating')
 Set which class SimplePie uses for <media:rating>
 
 set_raw_data ($data)
 Set the raw XML data to parse.
 
 set_restriction_class ($class='SimplePie_Restriction')
 Set which class SimplePie uses for <media:restriction>
 
 set_sanitize_class ($class='SimplePie_Sanitize')
 Set which class SimplePie uses for data sanitization.
 
 set_source_class ($class='SimplePie_Source')
 Set which class SimplePie uses item sources.
 
 set_stupidly_fast ($set=false)
 Set options to make SP as fast as possible.
 
 set_timeout ($timeout=10)
 Set the default timeout for fetching remote feeds.
 
 set_url_replacements ($element_attribute=null)
 Set element/attribute key/value pairs of HTML attributes containing URLs that need to be resolved relative to the feed.
 
 set_useragent ($ua=SIMPLEPIE_USERAGENT)
 #-
 
 status_code ()
 Get the last HTTP status code.
 
 strip_attributes ($attribs='')
 
 strip_comments ($strip=false)
 
 strip_htmltags ($tags='', $encode=null)
 
 subscribe_url ($permanent=false)
 Get the URL for the feed.
 

Static Public Member Functions

static merge_items ($urls, $start=0, $end=0, $limit=0)
 Merge items from several feeds into one.
 
static sort_items ($a, $b)
 Sorting callback for items.
 

Public Attributes

array $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'))
 Stores the default attributes to add to different tags by add_attributes().
 
array $all_discovered_feeds = array()
 All the feeds found during the autodiscovery process.
 
int $autodiscovery = SIMPLEPIE_LOCATOR_ALL
 Feed Autodiscovery Level.
 
int $autodiscovery_cache_duration = 604800
 Auto-discovery cache duration (in seconds)
 
bool $cache = true
 Enable/Disable Caching.
 
int $cache_duration = 3600
 Cache duration (in seconds)
 
string $cache_location = './cache'
 Cache location (relative to executing script)
 
string $cache_name_function = 'md5'
 Function that creates the cache filename.
 
bool $check_modified = false
 Stores if last-modified and/or etag headers were sent with the request when checking a feed.
 
array $config_settings = null
 Stores the get_object_vars() array for use with multifeeds.
 
array $curl_options = array()
 Custom curl options.
 
array $data = array()
 Raw data.
 
bool $enable_exceptions = false
 Should we throw exceptions, or use the old-style error property?
 
mixed $error
 Error string.
 
string $feed_url
 Feed URL.
 
object $file
 Instance of SimplePie_File to use as a feed.
 
bool $force_cache_fallback = false
 Force SimplePie to fallback to expired cache, if enabled, when feed is unavailable.
 
bool $force_feed = false
 Force the given data/URL to be treated as a feed no matter what it appears like.
 
bool $force_fsockopen = false
 Forces fsockopen() to be used for remote files instead of cURL, even if a new enough version is installed.
 
string $image_handler = ''
 Web-accessible path to the handler_image.php file.
 
mixed $input_encoding = false
 Force input encoding to be set to the follow value (false, or anything type-cast to false, disables this feature)
 
integer $item_limit = 0
 Stores the number of items to return per-feed with multifeeds.
 
int $max_checked_feeds = 10
 Maximum number of feeds to check with autodiscovery.
 
array $multifeed_objects = array()
 Stores SimplePie objects when multiple feeds initialized.
 
array $multifeed_url = array()
 Stores the URLs when multiple feeds are being initialized.
 
bool $order_by_date = true
 Reorder feed by date descending.
 
string $permanent_url = null
 Original feed URL, or new feed URL iff HTTP 301 Moved Permanently.
 
string $raw_data
 Raw feed data.
 
SimplePie_Registry $registry
 Class registry object.
 
array $rename_attributes = array()
 Stores the default attributes to be renamed by rename_attributes().
 
object $sanitize
 Instance of SimplePie_Sanitize (or other class)
 
int $status_code
 HTTP status code.
 
array $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')
 Stores the default attributes to be stripped by strip_attributes().
 
array $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')
 Stores the default tags to be stripped by strip_htmltags().
 
int $timeout = 10
 Timeout for fetching remote files.
 
string $useragent = SIMPLEPIE_USERAGENT
 SimplePie Useragent.
 

Protected Member Functions

 fetch_data (&$cache)
 Fetch the data via SimplePie_File.
 

Detailed Description

SimplePie.

@subpackage API

Constructor & Destructor Documentation

◆ __construct()

SimplePie::__construct ( )

The SimplePie class contains feed level data and options.

To use SimplePie, create the SimplePie object with no parameters. You can then set configuration options using the provided methods. After setting them, you must initialise the feed using $feed->init(). At that point the object's methods and properties will be available to you.

Previously, it was possible to pass in the feed URL along with cache options directly into the constructor. This has been removed as of 1.3 as it caused a lot of confusion.

Since
1.0 Preview Release

Member Function Documentation

◆ __call()

SimplePie::__call ( $method,
$args )

Magic method handler.

Parameters
string$methodMethod name
array$argsArguments to the method
Return values
mixed

◆ enable_cache()

SimplePie::enable_cache ( $enable = true)

Enable/disable caching in SimplePie.

This option allows you to disable caching all-together in SimplePie. However, disabling the cache can lead to longer load times.

Since
1.0 Preview Release
Parameters
bool$enableEnable caching

◆ enable_exceptions()

SimplePie::enable_exceptions ( $enable = true)

Enable throwing exceptions.

Parameters
boolean$enableShould we throw exceptions, or use the old-style error property?

◆ enable_order_by_date()

SimplePie::enable_order_by_date ( $enable = true)

Set whether feed items should be sorted into reverse chronological order.

Parameters
bool$enableSort as reverse chronological order.

◆ error()

SimplePie::error ( )

Get the error message for the occurred error.

Return values
string|arrayError message, or array of messages for multifeeds

◆ fetch_data()

SimplePie::fetch_data ( & $cache)
protected

Fetch the data via SimplePie_File.

If the data is already cached, attempt to fetch it from there instead

Parameters
SimplePie_Cache_Base | false$cacheCache handler, or false to not load from the cache
Return values
array|trueReturns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type

◆ force_cache_fallback()

SimplePie::force_cache_fallback ( $enable = false)

SimplePie to continue to fall back to expired cache, if enabled, when feed is unavailable.

This tells SimplePie to ignore any file errors and fall back to cache instead. This only works if caching is enabled and cached content still exists.

Parameters
bool$enableForce use of cache on fail.

◆ force_feed()

SimplePie::force_feed ( $enable = false)

Force the given data/URL to be treated as a feed.

This tells SimplePie to ignore the content-type provided by the server. Be careful when using this option, as it will also disable autodiscovery.

Since
1.1
Parameters
bool$enableForce the given data/URL to be treated as a feed

◆ force_fsockopen()

SimplePie::force_fsockopen ( $enable = false)

Force SimplePie to use fsockopen() instead of cURL.

Since
1.0 Beta 3
Parameters
bool$enableForce fsockopen() to be used

◆ get_author()

SimplePie::get_author ( $key = 0)

Get an author for the feed.

Since
1.1
Parameters
int$keyThe author that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie_Author|null

◆ get_authors()

SimplePie::get_authors ( )

Get all authors for the feed.

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

Since
1.1
Return values
array|nullList of {
See also
SimplePie_Author} objects

◆ get_base()

SimplePie::get_base ( $element = array())

Get the base URL value from the feed.

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

See also
get_link
subscribe_url
Parameters
array$element
Return values
string

◆ get_cache_filename()

SimplePie::get_cache_filename ( $url)

Return the filename (i.e.

hash, without path and without extension) of the file to cache a given URL.

Parameters
string$urlThe URL of the feed to be cached.
Return values
stringA filename (i.e. hash, without path and without extension).

◆ get_categories()

SimplePie::get_categories ( )

Get all categories for the feed.

Uses <atom:category>, <category> or <dc:subject>

Since
Unknown
Return values
array|nullList of {
See also
SimplePie_Category} objects

◆ get_category()

SimplePie::get_category ( $key = 0)

Get a category for the feed.

Since
Unknown
Parameters
int$keyThe category that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie_Category|null

◆ get_channel_tags()

SimplePie::get_channel_tags ( $namespace,
$tag )

Get data for an channel-level element.

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

See {

See also
SimplePie\get_feed_tags()} for a description of the return value
Since
1.0
See also
http://simplepie.org/wiki/faq/supported_xml_namespaces
Parameters
string$namespaceThe URL of the XML namespace of the elements you're trying to access
string$tagTag name
Return values
array

◆ get_contributor()

SimplePie::get_contributor ( $key = 0)

Get a contributor for the feed.

Since
1.1
Parameters
int$keyThe contrbutor that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie_Author|null

◆ get_contributors()

SimplePie::get_contributors ( )

Get all contributors for the feed.

Uses <atom:contributor>

Since
1.1
Return values
array|nullList of {
See also
SimplePie_Author} objects

◆ get_copyright()

SimplePie::get_copyright ( )

Get the copyright info for the feed.

Uses <atom:rights>, <atom:copyright> or <dc:rights>

Since
1.0 (previously called get_feed_copyright() since 0.8)
Return values
string|null

◆ get_description()

SimplePie::get_description ( )

Get the content for the item.

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

Since
1.0 (previously called get_feed_description() since 0.8)
Return values
string|null

◆ get_encoding()

SimplePie::get_encoding ( )

Get the character encoding used for output.

Since
Preview Release
Return values
string

◆ get_favicon()

SimplePie::get_favicon ( )

Get the favicon for the current feed.

Deprecated
Use your own favicon handling instead

◆ get_feed_tags()

SimplePie::get_feed_tags ( $namespace,
$tag )

Get data for an feed-level element.

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
// <media:content> 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;
Since
1.0
See also
http://simplepie.org/wiki/faq/supported_xml_namespaces
Parameters
string$namespaceThe URL of the XML namespace of the elements you're trying to access
string$tagTag name
Return values
array

◆ get_image_height()

SimplePie::get_image_height ( )

Get the feed logo's height.

RSS 2.0 feeds are allowed to have a "feed logo" height.

Uses <image><height> or defaults to 31.0 if no height is specified and the feed is an RSS 2.0 feed.

Return values
int|float|null

◆ get_image_link()

SimplePie::get_image_link ( )

Get the feed logo's link.

RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" link. This points to a human-readable page that the image should link to.

Uses <itunes:image>, <atom:logo>, <atom:icon>, <image><title> or <image><dc:title>

Return values
string|null

◆ get_image_tags()

SimplePie::get_image_tags ( $namespace,
$tag )

Get data for an channel-level element.

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

See {

See also
SimplePie\get_feed_tags()} for a description of the return value
Since
1.0
See also
http://simplepie.org/wiki/faq/supported_xml_namespaces
Parameters
string$namespaceThe URL of the XML namespace of the elements you're trying to access
string$tagTag name
Return values
array

◆ get_image_title()

SimplePie::get_image_title ( )

Get the feed logo's title.

RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" title.

Uses <image><title> or <image><dc:title>

Return values
string|null

◆ get_image_url()

SimplePie::get_image_url ( )

Get the feed logo's URL.

RSS 0.9.0, 2.0, Atom 1.0, and feeds with iTunes RSS tags are allowed to have a "feed logo" URL. This points directly to the image itself.

Uses <itunes:image>, <atom:logo>, <atom:icon>, <image><title> or <image><dc:title>

Return values
string|null

◆ get_image_width()

SimplePie::get_image_width ( )

Get the feed logo's link.

RSS 2.0 feeds are allowed to have a "feed logo" width.

Uses <image><width> or defaults to 88.0 if no width is specified and the feed is an RSS 2.0 feed.

Return values
int|float|null

◆ get_item()

SimplePie::get_item ( $key = 0)

Get a single item from the feed.

This is better suited for for() loops, whereas {

See also
get_items()} is better suited for foreach() loops.
get_item_quantity()
Since
Beta 2
Parameters
int$keyThe item that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie_Item|null

◆ get_item_quantity()

SimplePie::get_item_quantity ( $max = 0)

Get the number of items in the feed.

This is well-suited for for() loops with {

See also
get_item()}
Parameters
int$maxMaximum value to return. 0 for no limit
Return values
intNumber of items in the feed

◆ get_items()

SimplePie::get_items ( $start = 0,
$end = 0 )

Get all items from the feed.

This is better suited for for() loops, whereas {

See also
get_items()} is better suited for foreach() loops.
get_item_quantity
Since
Beta 2
Parameters
int$startIndex to start at
int$endNumber of items to return. 0 for all items after $start
Return values
SimplePie_Item[]|nullList of {
See also
SimplePie_Item} objects

◆ get_language()

SimplePie::get_language ( )

Get the language for the feed.

Uses <language>, <dc:language>, or @xml_lang

Since
1.0 (previously called get_feed_language() since 0.8)
Return values
string|null

◆ get_latitude()

SimplePie::get_latitude ( )

Get the latitude coordinates for the item.

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

Uses <geo:lat> or <georss:point>

Since
1.0 @externalurl http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo @externalurl http://www.georss.org/ GeoRSS
Return values
string|null

◆ get_link()

SimplePie::get_link ( $key = 0,
$rel = 'alternate' )

Get a single link for the feed.

Since
1.0 (previously called get_feed_link since Preview Release, get_feed_permalink() since 0.8)
Parameters
int$keyThe link that you want to return. Remember that arrays begin with 0, not 1
string$relThe relationship of the link to return
Return values
string|nullLink URL

◆ get_links()

SimplePie::get_links ( $rel = 'alternate')

Get all links for the feed.

Uses <atom:link> or <link>

Since
Beta 2
Parameters
string$relThe relationship of links to return
Return values
array|nullLinks found for the feed (strings)

◆ get_longitude()

SimplePie::get_longitude ( )

Get the longitude coordinates for the feed.

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

Uses <geo:long>, <geo:lon> or <georss:point>

Since
1.0 @externalurl http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo @externalurl http://www.georss.org/ GeoRSS
Return values
string|null

◆ get_permalink()

SimplePie::get_permalink ( )

Get the permalink for the item.

Returns the first link available with a relationship of "alternate". Identical to {

See also
get_link()} with key 0
get_link
Since
1.0 (previously called get_feed_link since Preview Release, get_feed_permalink() since 0.8)

◆ get_raw_data()

SimplePie::get_raw_data ( )

Get the raw XML.

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

Return values
string|booleanRaw XML data, false if the cache is used

◆ get_registry()

& SimplePie::get_registry ( )

Get the class registry.

Use this to override SimplePie's default classes

See also
SimplePie_Registry
Return values
SimplePie_Registry

◆ get_title()

SimplePie::get_title ( )

Get the title of the feed.

Uses <atom:title>, <title> or <dc:title>

Since
1.0 (previously called get_feed_title since 0.8)
Return values
string|null

◆ get_type()

SimplePie::get_type ( )

Get the type of the feed.

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

Since
0.8 (usage changed to using constants in 1.0)
See also
SIMPLEPIE_TYPE_NONE Unknown.
SIMPLEPIE_TYPE_RSS_090 RSS 0.90.
SIMPLEPIE_TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).
SIMPLEPIE_TYPE_RSS_091_USERLAND RSS 0.91 (Userland).
SIMPLEPIE_TYPE_RSS_091 RSS 0.91.
SIMPLEPIE_TYPE_RSS_092 RSS 0.92.
SIMPLEPIE_TYPE_RSS_093 RSS 0.93.
SIMPLEPIE_TYPE_RSS_094 RSS 0.94.
SIMPLEPIE_TYPE_RSS_10 RSS 1.0.
SIMPLEPIE_TYPE_RSS_20 RSS 2.0.x.
SIMPLEPIE_TYPE_RSS_RDF RDF-based RSS.
SIMPLEPIE_TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).
SIMPLEPIE_TYPE_RSS_ALL Any version of RSS.
SIMPLEPIE_TYPE_ATOM_03 Atom 0.3.
SIMPLEPIE_TYPE_ATOM_10 Atom 1.0.
SIMPLEPIE_TYPE_ATOM_ALL Any version of Atom.
SIMPLEPIE_TYPE_ALL Any known/supported feed type.
Return values
intSIMPLEPIE_TYPE_* constant

◆ handle_content_type()

SimplePie::handle_content_type ( $mime = 'text/html')

Send the content-type header with correct encoding.

This method ensures that the SimplePie-enabled page is being served with the correct mime-type and character encoding HTTP headers (character encoding determined by the {

See also
set_output_encoding} config option).

This won't work properly if any content or whitespace has already been sent to the browser, because it relies on PHP's header() function, and these are the circumstances under which the function works.

Because it's setting these settings for the entire page (as is the nature of HTTP headers), this should only be used once per page (again, at the top).

Parameters
string$mimeMIME type to serve the page as

◆ init()

SimplePie::init ( )

Initialize the feed object.

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
booleanTrue if successful, false otherwise

◆ merge_items()

static SimplePie::merge_items ( $urls,
$start = 0,
$end = 0,
$limit = 0 )
static

Merge items from several feeds into one.

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

@externalurl http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings

Parameters
array$urlsList of SimplePie feed objects to merge
int$startStarting item
int$endNumber of items to return
int$limitMaximum number of items per feed
Return values
array

◆ sanitize()

SimplePie::sanitize ( $data,
$type,
$base = '' )

Sanitize feed data.

See also
SimplePie_Sanitize\sanitize()
Parameters
string$dataData to sanitize
int$typeOne of the SIMPLEPIE_CONSTRUCT_* constants
string$baseBase URL to resolve URLs against
Return values
stringSanitized data

◆ set_autodiscovery_cache_duration()

SimplePie::set_autodiscovery_cache_duration ( $seconds = 604800)

Set the length of time (in seconds) that the autodiscovered feed URL will be cached.

Parameters
int$secondsThe autodiscovered feed URL cache duration.

◆ set_autodiscovery_level()

SimplePie::set_autodiscovery_level ( $level = SIMPLEPIE_LOCATOR_ALL)

Set how much feed autodiscovery to do.

See also
SIMPLEPIE_LOCATOR_NONE
SIMPLEPIE_LOCATOR_AUTODISCOVERY
SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
SIMPLEPIE_LOCATOR_LOCAL_BODY
SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
SIMPLEPIE_LOCATOR_REMOTE_BODY
SIMPLEPIE_LOCATOR_ALL
Parameters
int$levelFeed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator)

◆ set_cache_class()

SimplePie::set_cache_class ( $class = 'SimplePie_Cache')

#+ Useful when you are overloading or extending SimplePie's default classes.

Deprecated
Use {
See also
get_registry()} instead @externalurl http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
Parameters
string$className of custom class
Return values
booleanTrue on success, false otherwise Set which class SimplePie uses for caching

◆ set_cache_duration()

SimplePie::set_cache_duration ( $seconds = 3600)

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

Parameters
int$secondsThe feed content cache duration

◆ set_cache_location()

SimplePie::set_cache_location ( $location = './cache')

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

Parameters
string$locationThe file system location.

◆ set_cache_name_function()

SimplePie::set_cache_name_function ( $function = 'md5')

Set callback function to create cache filename with.

Parameters
mixed$functionCallback function

◆ set_curl_options()

SimplePie::set_curl_options ( array $curl_options = array())

Set custom curl options.

This allows you to change default curl options

Since
1.0 Beta 3
Parameters
array$curl_optionsCurl options to add to default settings

◆ set_favicon_handler()

SimplePie::set_favicon_handler ( $page = false,
$qs = 'i' )

Set the favicon handler.

Deprecated
Use your own favicon handling instead

◆ set_feed_url()

SimplePie::set_feed_url ( $url)

Set the URL of the feed you want to parse.

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.

Since
1.0 Preview Release
See also
set_raw_data()
Parameters
string | array$urlThis is the URL (or array of URLs) that you want to parse.

◆ set_file()

SimplePie::set_file ( & $file)

Set an instance of {.

See also
SimplePie_File} to use as a feed
Parameters
SimplePie_File&$file
Return values
boolTrue on success, false on failure

◆ set_https_domains()

SimplePie::set_https_domains ( $domains = array())

Set the list of domains for which to force HTTPS.

See also
SimplePie_Sanitize\set_https_domains()
Parameters
arrayList of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').

◆ set_image_handler()

SimplePie::set_image_handler ( $page = false,
$qs = 'i' )

Set the handler to enable the display of cached images.

Parameters
string$pageWeb-accessible path to the handler_image.php file.
string$qsThe query string that the value should be passed to.

◆ set_input_encoding()

SimplePie::set_input_encoding ( $encoding = false)

Set the character encoding used to parse the feed.

This overrides the encoding reported by the feed, however it will fall back to the normal encoding detection if the override fails

Parameters
string$encodingCharacter encoding

◆ set_item_limit()

SimplePie::set_item_limit ( $limit = 0)

Set the limit for items returned per-feed with multifeeds.

Parameters
integer$limitThe maximum number of items to return.

◆ set_max_checked_feeds()

SimplePie::set_max_checked_feeds ( $max = 10)

Set maximum number of feeds to check with autodiscovery.

Parameters
int$maxMaximum number of feeds to check

◆ set_output_encoding()

SimplePie::set_output_encoding ( $encoding = 'UTF-8')

Set the output encoding.

Allows you to override SimplePie's output to match that of your webpage. This is useful for times when your webpages are not being served as UTF-8. This setting will be obeyed by {

See also
handle_content_type()}, and is similar to {
set_input_encoding()}.

It should be noted, however, that not all character encodings can support all characters. If your page is being served as ISO-8859-1 and you try to display a Japanese feed, you'll likely see garbled characters. Because of this, it is highly recommended to ensure that your webpages are served as UTF-8.

The number of supported character encodings depends on whether your web host supports mbstring, iconv, or both. See for more information.

Parameters
string$encoding

◆ set_raw_data()

SimplePie::set_raw_data ( $data)

Set the raw XML data to parse.

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.

Since
1.0 Beta 3
Parameters
string$dataRSS or Atom data as a string.
See also
set_feed_url()

◆ set_stupidly_fast()

SimplePie::set_stupidly_fast ( $set = false)

Set options to make SP as fast as possible.

Forgoes a substantial amount of data sanitization in favor of speed. This turns SimplePie into a dumb parser of feeds.

Parameters
bool$setWhether to set them or not

◆ set_timeout()

SimplePie::set_timeout ( $timeout = 10)

Set the default timeout for fetching remote feeds.

This allows you to change the maximum time the feed's server to respond and send the feed back.

Since
1.0 Beta 3
Parameters
int$timeoutThe maximum number of seconds to spend waiting to retrieve a feed.

◆ set_url_replacements()

SimplePie::set_url_replacements ( $element_attribute = null)

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

Defaults to |a|@href, |area|@href, |blockquote|

◆ set_useragent()

SimplePie::set_useragent ( $ua = SIMPLEPIE_USERAGENT)

#-

Set the user agent string

Parameters
string$uaNew user agent string.

◆ sort_items()

static SimplePie::sort_items ( $a,
$b )
static

Sorting callback for items.

Parameters
SimplePie$a
SimplePie$b
Return values
boolean

◆ status_code()

SimplePie::status_code ( )

Get the last HTTP status code.

Return values
intStatus code

◆ subscribe_url()

SimplePie::subscribe_url ( $permanent = false)

Get the URL for the feed.

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 {

See also
set_feed_url()}, depending on whether auto-discovery was used, and whether there were any redirects along the way.
Since
Preview Release (previously called get_feed_url() since SimplePie 0.8.)
Todo

Support <itunes:new-feed-url>

Also, |atom:link|@rel=self

Parameters
bool$permanentPermanent mode to return only the original URL or the first redirection iff it is a 301 redirection
Return values
string|null

Member Data Documentation

◆ $add_attributes

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

Stores the default attributes to add to different tags by add_attributes().

See also
SimplePie\add_attributes()

◆ $all_discovered_feeds

array SimplePie::$all_discovered_feeds = array()

All the feeds found during the autodiscovery process.

See also
SimplePie\get_all_discovered_feeds()

◆ $autodiscovery

int SimplePie::$autodiscovery = SIMPLEPIE_LOCATOR_ALL

Feed Autodiscovery Level.

See also
SimplePie\set_autodiscovery_level()

◆ $autodiscovery_cache_duration

int SimplePie::$autodiscovery_cache_duration = 604800

Auto-discovery cache duration (in seconds)

See also
SimplePie\set_autodiscovery_cache_duration()

◆ $cache

bool SimplePie::$cache = true

Enable/Disable Caching.

See also
SimplePie\enable_cache()

◆ $cache_duration

int SimplePie::$cache_duration = 3600

Cache duration (in seconds)

See also
SimplePie\set_cache_duration()

◆ $cache_location

string SimplePie::$cache_location = './cache'

Cache location (relative to executing script)

See also
SimplePie\set_cache_location()

◆ $cache_name_function

string SimplePie::$cache_name_function = 'md5'

Function that creates the cache filename.

See also
SimplePie\set_cache_name_function()

◆ $config_settings

array SimplePie::$config_settings = null

Stores the get_object_vars() array for use with multifeeds.

See also
SimplePie\set_feed_url()

◆ $curl_options

array SimplePie::$curl_options = array()

Custom curl options.

See also
SimplePie\set_curl_options()

◆ $feed_url

string SimplePie::$feed_url

Feed URL.

See also
SimplePie\set_feed_url()

◆ $file

object SimplePie::$file

Instance of SimplePie_File to use as a feed.

See also
SimplePie\set_file()

◆ $force_cache_fallback

bool SimplePie::$force_cache_fallback = false

Force SimplePie to fallback to expired cache, if enabled, when feed is unavailable.

See also
SimplePie\force_cache_fallback()

◆ $force_feed

bool SimplePie::$force_feed = false

Force the given data/URL to be treated as a feed no matter what it appears like.

See also
SimplePie\force_feed()

◆ $force_fsockopen

bool SimplePie::$force_fsockopen = false

Forces fsockopen() to be used for remote files instead of cURL, even if a new enough version is installed.

See also
SimplePie\force_fsockopen()

◆ $image_handler

string SimplePie::$image_handler = ''

Web-accessible path to the handler_image.php file.

See also
SimplePie\set_image_handler()

◆ $input_encoding

mixed SimplePie::$input_encoding = false

Force input encoding to be set to the follow value (false, or anything type-cast to false, disables this feature)

See also
SimplePie\set_input_encoding()

◆ $item_limit

integer SimplePie::$item_limit = 0

Stores the number of items to return per-feed with multifeeds.

See also
SimplePie\set_item_limit()

◆ $max_checked_feeds

int SimplePie::$max_checked_feeds = 10

Maximum number of feeds to check with autodiscovery.

See also
SimplePie\set_max_checked_feeds()

◆ $multifeed_url

array SimplePie::$multifeed_url = array()

Stores the URLs when multiple feeds are being initialized.

See also
SimplePie\set_feed_url()

◆ $order_by_date

bool SimplePie::$order_by_date = true

Reorder feed by date descending.

See also
SimplePie\enable_order_by_date()

◆ $permanent_url

string SimplePie::$permanent_url = null

Original feed URL, or new feed URL iff HTTP 301 Moved Permanently.

See also
SimplePie\subscribe_url()

◆ $raw_data

string SimplePie::$raw_data

Raw feed data.

See also
SimplePie\set_raw_data()

◆ $rename_attributes

array SimplePie::$rename_attributes = array()

Stores the default attributes to be renamed by rename_attributes().

See also
SimplePie\rename_attributes()

◆ $sanitize

object SimplePie::$sanitize

Instance of SimplePie_Sanitize (or other class)

See also
SimplePie\set_sanitize_class()

◆ $status_code

int SimplePie::$status_code

HTTP status code.

See also
SimplePie\status_code()

◆ $strip_attributes

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

Stores the default attributes to be stripped by strip_attributes().

See also
SimplePie\strip_attributes()

◆ $strip_htmltags

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

Stores the default tags to be stripped by strip_htmltags().

See also
SimplePie\strip_htmltags()

◆ $timeout

int SimplePie::$timeout = 10

Timeout for fetching remote files.

See also
SimplePie\set_timeout()

◆ $useragent

string SimplePie::$useragent = SIMPLEPIE_USERAGENT

SimplePie Useragent.

See also
SimplePie\set_useragent()

The documentation for this class was generated from the following file: