Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
|
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. | |
@subpackage API
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.
SimplePie::__call | ( | $method, | |
$args ) |
Magic method handler.
string | $method | Method name |
array | $args | Arguments to the method |
mixed |
SimplePie::enable_cache | ( | $enable = true | ) |
SimplePie::enable_exceptions | ( | $enable = true | ) |
Enable throwing exceptions.
boolean | $enable | Should we throw exceptions, or use the old-style error property? |
SimplePie::enable_order_by_date | ( | $enable = true | ) |
Set whether feed items should be sorted into reverse chronological order.
bool | $enable | Sort as reverse chronological order. |
SimplePie::error | ( | ) |
Get the error message for the occurred error.
string|array | Error message, or array of messages for multifeeds |
|
protected |
Fetch the data via SimplePie_File.
If the data is already cached, attempt to fetch it from there instead
SimplePie_Cache_Base | false | $cache | Cache handler, or false to not load from the cache |
array|true | Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type |
SimplePie::force_cache_fallback | ( | $enable = false | ) |
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.
bool | $enable | Force the given data/URL to be treated as a feed |
SimplePie::force_fsockopen | ( | $enable = false | ) |
Force SimplePie to use fsockopen() instead of cURL.
bool | $enable | Force fsockopen() to be used |
SimplePie::get_author | ( | $key = 0 | ) |
Get an author for the feed.
int | $key | The author that you want to return. Remember that arrays begin with 0, not 1 |
SimplePie_Author|null |
SimplePie::get_authors | ( | ) |
Get all authors for the feed.
Uses <atom:author>
, <author>
, <dc:creator>
or <itunes:author>
array|null | List of { |
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.
array | $element |
string |
SimplePie::get_cache_filename | ( | $url | ) |
Return the filename (i.e.
hash, without path and without extension) of the file to cache a given URL.
string | $url | The URL of the feed to be cached. |
string | A filename (i.e. hash, without path and without extension). |
SimplePie::get_categories | ( | ) |
Get all categories for the feed.
Uses <atom:category>
, <category>
or <dc:subject>
array|null | List of { |
SimplePie::get_category | ( | $key = 0 | ) |
Get a category for the feed.
int | $key | The category that you want to return. Remember that arrays begin with 0, not 1 |
SimplePie_Category|null |
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 {
string | $namespace | The URL of the XML namespace of the elements you're trying to access |
string | $tag | Tag name |
array |
SimplePie::get_contributor | ( | $key = 0 | ) |
Get a contributor for the feed.
int | $key | The contrbutor that you want to return. Remember that arrays begin with 0, not 1 |
SimplePie_Author|null |
SimplePie::get_contributors | ( | ) |
Get all contributors for the feed.
Uses <atom:contributor>
array|null | List of { |
SimplePie::get_copyright | ( | ) |
Get the copyright info for the feed.
Uses <atom:rights>
, <atom:copyright>
or <dc:rights>
get_feed_copyright()
since 0.8) string|null |
SimplePie::get_description | ( | ) |
Get the content for the item.
Uses <atom:subtitle>
, <atom:tagline>
, <description>
, <dc:description>
, <itunes:summary>
or <itunes:subtitle>
get_feed_description()
since 0.8) string|null |
SimplePie::get_encoding | ( | ) |
Get the character encoding used for output.
string |
SimplePie::get_favicon | ( | ) |
Get the favicon for the current feed.
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;
string | $namespace | The URL of the XML namespace of the elements you're trying to access |
string | $tag | Tag name |
array |
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.
int|float|null |
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>
string|null |
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 {
string | $namespace | The URL of the XML namespace of the elements you're trying to access |
string | $tag | Tag name |
array |
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>
string|null |
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>
string|null |
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.
int|float|null |
SimplePie::get_item | ( | $key = 0 | ) |
SimplePie::get_item_quantity | ( | $max = 0 | ) |
Get the number of items in the feed.
This is well-suited for for() loops with {
int | $max | Maximum value to return. 0 for no limit |
int | Number of items in the feed |
SimplePie::get_items | ( | $start = 0, | |
$end = 0 ) |
Get all items from the feed.
This is better suited for for() loops, whereas {
int | $start | Index to start at |
int | $end | Number of items to return. 0 for all items after $start |
SimplePie_Item[]|null | List of { |
SimplePie::get_language | ( | ) |
Get the language for the feed.
Uses <language>
, <dc:language>
, or @xml_lang
get_feed_language()
since 0.8) string|null |
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>
string|null |
SimplePie::get_link | ( | $key = 0, | |
$rel = 'alternate' ) |
Get a single link for the feed.
get_feed_link
since Preview Release, get_feed_permalink()
since 0.8) int | $key | The link that you want to return. Remember that arrays begin with 0, not 1 |
string | $rel | The relationship of the link to return |
string|null | Link URL |
SimplePie::get_links | ( | $rel = 'alternate' | ) |
Get all links for the feed.
Uses <atom:link>
or <link>
string | $rel | The relationship of links to return |
array|null | Links found for the feed (strings) |
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>
string|null |
SimplePie::get_permalink | ( | ) |
Get the permalink for the item.
Returns the first link available with a relationship of "alternate". Identical to {
get_feed_link
since Preview Release, get_feed_permalink()
since 0.8) 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.
string|boolean | Raw XML data, false if the cache is used |
& SimplePie::get_registry | ( | ) |
Get the class registry.
Use this to override SimplePie's default classes
SimplePie_Registry |
SimplePie::get_title | ( | ) |
Get the title of the feed.
Uses <atom:title>
, <title>
or <dc:title>
get_feed_title
since 0.8) string|null |
SimplePie::get_type | ( | ) |
Get the type of the feed.
This returns a SIMPLEPIE_TYPE_* constant, which can be tested against using bitwise operators
int | SIMPLEPIE_TYPE_* constant |
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 {
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).
string | $mime | MIME type to serve the page as |
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.
boolean | True if successful, false otherwise |
|
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
array | $urls | List of SimplePie feed objects to merge |
int | $start | Starting item |
int | $end | Number of items to return |
int | $limit | Maximum number of items per feed |
array |
SimplePie::sanitize | ( | $data, | |
$type, | |||
$base = '' ) |
Sanitize feed data.
string | $data | Data to sanitize |
int | $type | One of the SIMPLEPIE_CONSTRUCT_* constants |
string | $base | Base URL to resolve URLs against |
string | Sanitized data |
SimplePie::set_autodiscovery_cache_duration | ( | $seconds = 604800 | ) |
Set the length of time (in seconds) that the autodiscovered feed URL will be cached.
int | $seconds | The autodiscovered feed URL cache duration. |
SimplePie::set_autodiscovery_level | ( | $level = SIMPLEPIE_LOCATOR_ALL | ) |
Set how much feed autodiscovery to do.
int | $level | Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator) |
SimplePie::set_cache_class | ( | $class = 'SimplePie_Cache' | ) |
#+ Useful when you are overloading or extending SimplePie's default classes.
string | $class | Name of custom class |
boolean | True on success, false otherwise Set which class SimplePie uses for caching |
SimplePie::set_cache_duration | ( | $seconds = 3600 | ) |
Set the length of time (in seconds) that the contents of a feed will be cached.
int | $seconds | The feed content cache duration |
SimplePie::set_cache_location | ( | $location = './cache' | ) |
Set the file system location where the cached files should be stored.
string | $location | The file system location. |
SimplePie::set_cache_name_function | ( | $function = 'md5' | ) |
Set callback function to create cache filename with.
mixed | $function | Callback function |
SimplePie::set_curl_options | ( | array | $curl_options = array() | ) |
Set custom curl options.
This allows you to change default curl options
array | $curl_options | Curl options to add to default settings |
SimplePie::set_favicon_handler | ( | $page = false, | |
$qs = 'i' ) |
Set the favicon handler.
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.
string | array | $url | This is the URL (or array of URLs) that you want to parse. |
SimplePie::set_file | ( | & | $file | ) |
Set an instance of {.
SimplePie_File | &$file |
bool | True on success, false on failure |
SimplePie::set_https_domains | ( | $domains = array() | ) |
Set the list of domains for which to force HTTPS.
array | List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net'). |
SimplePie::set_image_handler | ( | $page = false, | |
$qs = 'i' ) |
Set the handler to enable the display of cached images.
string | $page | Web-accessible path to the handler_image.php file. |
string | $qs | The query string that the value should be passed to. |
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
string | $encoding | Character encoding |
SimplePie::set_item_limit | ( | $limit = 0 | ) |
Set the limit for items returned per-feed with multifeeds.
integer | $limit | The maximum number of items to return. |
SimplePie::set_max_checked_feeds | ( | $max = 10 | ) |
Set maximum number of feeds to check with autodiscovery.
int | $max | Maximum number of feeds to check |
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 {
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.
string | $encoding |
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.
string | $data | RSS or Atom data as a string. |
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.
bool | $set | Whether to set them or not |
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.
int | $timeout | The maximum number of seconds to spend waiting to retrieve a feed. |
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|
SimplePie::set_useragent | ( | $ua = SIMPLEPIE_USERAGENT | ) |
#-
Set the user agent string
string | $ua | New user agent string. |
|
static |
SimplePie::status_code | ( | ) |
Get the last HTTP status code.
int | Status code |
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 {
get_feed_url()
since SimplePie 0.8.) Support <itunes:new-feed-url>
Also, |atom:link|@rel=self
bool | $permanent | Permanent mode to return only the original URL or the first redirection iff it is a 301 redirection |
string|null |
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().
array SimplePie::$all_discovered_feeds = array() |
All the feeds found during the autodiscovery process.
int SimplePie::$autodiscovery = SIMPLEPIE_LOCATOR_ALL |
Feed Autodiscovery Level.
int SimplePie::$autodiscovery_cache_duration = 604800 |
Auto-discovery cache duration (in seconds)
bool SimplePie::$cache = true |
Enable/Disable Caching.
int SimplePie::$cache_duration = 3600 |
Cache duration (in seconds)
string SimplePie::$cache_location = './cache' |
Cache location (relative to executing script)
string SimplePie::$cache_name_function = 'md5' |
Function that creates the cache filename.
array SimplePie::$config_settings = null |
Stores the get_object_vars() array for use with multifeeds.
array SimplePie::$curl_options = array() |
Custom curl options.
string SimplePie::$feed_url |
Feed URL.
object SimplePie::$file |
Instance of SimplePie_File to use as a feed.
bool SimplePie::$force_cache_fallback = false |
Force SimplePie to fallback to expired cache, if enabled, when feed is unavailable.
bool SimplePie::$force_feed = false |
Force the given data/URL to be treated as a feed no matter what it appears like.
bool SimplePie::$force_fsockopen = false |
Forces fsockopen() to be used for remote files instead of cURL, even if a new enough version is installed.
string SimplePie::$image_handler = '' |
Web-accessible path to the handler_image.php file.
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)
integer SimplePie::$item_limit = 0 |
Stores the number of items to return per-feed with multifeeds.
int SimplePie::$max_checked_feeds = 10 |
Maximum number of feeds to check with autodiscovery.
array SimplePie::$multifeed_url = array() |
Stores the URLs when multiple feeds are being initialized.
bool SimplePie::$order_by_date = true |
Reorder feed by date descending.
string SimplePie::$permanent_url = null |
Original feed URL, or new feed URL iff HTTP 301 Moved Permanently.
string SimplePie::$raw_data |
Raw feed data.
array SimplePie::$rename_attributes = array() |
Stores the default attributes to be renamed by rename_attributes().
object SimplePie::$sanitize |
Instance of SimplePie_Sanitize (or other class)
int SimplePie::$status_code |
HTTP status code.
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().
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().
int SimplePie::$timeout = 10 |
Timeout for fetching remote files.
string SimplePie::$useragent = SIMPLEPIE_USERAGENT |
SimplePie Useragent.