SimplePie
package | SimplePie |
---|---|
subpackage | API |
__call(string $method, array $args) : mixed
string
Method name
array
Arguments to the method
mixed
__construct()
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 |
---|
__destruct()
__toString()
enable_cache(boolean $enable = true
)
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 |
---|
boolean
Enable caching
enable_order_by_date(boolean $enable = true
)
boolean
Sort as reverse chronological order.
encode_instead_of_strip($enable = true
)
error() : string | array
string
array
Error message, or array of messages for multifeedsforce_feed(boolean $enable = false
)
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 |
---|
boolean
Force the given data/URL to be treated as a feed
force_fsockopen(boolean $enable = false
)
since | 1.0 Beta 3 |
---|
boolean
Force fsockopen() to be used
get_all_discovered_feeds()
get_base(array $element = array()
) : string
get_categories() : array | null
Uses <atom:category>
, <category>
or <dc:subject>
since | Unknown |
---|
array
null
List of {@see SimplePie_Category} objectsget_category(integer $key = 0
) : \SimplePie_Category | null
since | Unknown |
---|
integer
The category that you want to return. Remember that arrays begin with 0, not 1
\SimplePie_Category
null
get_contributor(integer $key = 0
) : \SimplePie_Author | null
since | 1.1 |
---|
integer
The contrbutor that you want to return. Remember that arrays begin with 0, not 1
\SimplePie_Author
null
get_contributors() : array | null
Uses <atom:contributor>
since | 1.1 |
---|
array
null
List of {@see SimplePie_Author} objectsget_copyright() : string | null
Uses <atom:rights>
, <atom:copyright>
or <dc:rights>
since | 1.0 (previously called `get_feed_copyright()` since 0.8) |
---|
string
null
get_description() : string | null
Uses <atom:subtitle>
, <atom:tagline>
, <description>
,
<dc:description>
, <itunes:summary>
or <itunes:subtitle>
since | 1.0 (previously called `get_feed_description()` since 0.8) |
---|
string
null
get_encoding() : string
since | Preview Release |
---|
string
get_favicon()
deprecated | Use your own favicon handling instead |
---|
get_image_height() : integer | float | null
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.
integer
float
null
get_image_link() : string | null
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
get_image_title() : string | null
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
get_image_url() : string | null
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
get_image_width() : integer | float | null
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.
integer
float
null
get_item(integer $key = 0
) : \SimplePie_Item | null
get_item_quantity(integer $max = 0
) : integer
This is well-suited for for() loops with \get_item()
integer
Maximum value to return. 0 for no limit
integer
Number of items in the feedget_items(integer $start= 0
, integer $end= 0
) : array | null
get_language() : string | null
Uses <language>
, <dc:language>
, or @xml_lang
since | 1.0 (previously called `get_feed_language()` since 0.8) |
---|
string
null
get_latitude() : string | null
Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
Uses <geo:lat>
or <georss:point>
since | 1.0 |
---|---|
link | W3C WGS84 Basic Geo |
link | GeoRSS |
string
null
get_link(integer $key= 0
, string $rel= 'alternate'
) : string | null
since | 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) |
---|
integer
The link that you want to return. Remember that arrays begin with 0, not 1
string
The relationship of the link to return
string
null
Link URLget_links(string $rel = 'alternate'
) : array | null
Uses <atom:link>
or <link>
since | Beta 2 |
---|
string
The relationship of links to return
array
null
Links found for the feed (strings)get_longitude() : string | null
Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
Uses <geo:long>
, <geo:lon>
or <georss:point>
since | 1.0 |
---|---|
link | W3C WGS84 Basic Geo |
link | GeoRSS |
string
null
get_raw_data() : string | boolean
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 usedget_registry() : \SimplePie_Registry
get_title() : string | null
Uses <atom:title>
, <title>
or <dc:title>
since | 1.0 (previously called `get_feed_title` since 0.8) |
---|
string
null
get_type() : integer
This returns a SIMPLEPIETYPE* constant, which can be tested against using bitwise operators
since | 0.8 (usage changed to using constants in 1.0) |
---|---|
see | Unknown. |
see | RSS 0.90. |
see | RSS 0.91 (Netscape). |
see | RSS 0.91 (Userland). |
see | RSS 0.91. |
see | RSS 0.92. |
see | RSS 0.93. |
see | RSS 0.94. |
see | RSS 1.0. |
see | RSS 2.0.x. |
see | RDF-based RSS. |
see | Non-RDF-based RSS (truly intended as syndication format). |
see | Any version of RSS. |
see | Atom 0.3. |
see | Atom 1.0. |
see | Any version of Atom. |
see | Any known/supported feed type. |
integer
SIMPLEPIE_TYPE_* constanthandle_content_type(string $mime = 'text/html'
)
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 \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).
string
MIME type to serve the page as
init() : boolean
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 otherwisemerge_items(array $urls, integer $start= 0
, integer $end= 0
, integer $limit= 0
) : array
If you're merging multiple feeds together, they need to all have dates for the items or else SimplePie will refuse to sort them.
link | http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings |
---|
array
List of SimplePie feed objects to merge
integer
Starting item
integer
Number of items to return
integer
Maximum number of items per feed
array
remove_div($enable = true
)
sanitize(string $data, integer $type, string $base = ''
) : string
set_autodiscovery_cache_duration(integer $seconds = 604800
)
integer
The autodiscovered feed URL cache duration.
set_autodiscovery_level(integer $level = SIMPLEPIE_LOCATOR_ALL
)
set_cache_class($class = 'SimplePie_Cache'
)
set_cache_duration(integer $seconds = 3600
)
integer
The feed content cache duration
set_cache_location(string $location = './cache'
)
string
The file system location.
set_cache_name_function(mixed $function = 'md5'
)
mixed
Callback function
set_category_class($class = 'SimplePie_Category'
)
set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer'
)
set_copyright_class($class = 'SimplePie_Copyright'
)
set_credit_class($class = 'SimplePie_Credit'
)
set_enclosure_class($class = 'SimplePie_Enclosure'
)
set_favicon_handler($page= false
, $qs= 'i'
)
deprecated | Use your own favicon handling instead |
---|
set_feed_url(string|array $url)
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 |
string
array
This is the URL (or array of URLs) that you want to parse.
set_file(\SimplePie_File $file) : boolean
\SimplePie_File
&$file
boolean
True on success, false on failureset_file_class($class = 'SimplePie_File'
)
set_image_handler(\str $page= false
, \str $qs= 'i'
)
\str
Web-accessible path to the handler_image.php file.
\str
The query string that the value should be passed to.
set_input_encoding(string $encoding = false
)
This overrides the encoding reported by the feed, however it will fall back to the normal encoding detection if the override fails
string
Character encoding
set_item_class($class = 'SimplePie_Item'
)
set_item_limit(integer $limit = 0
)
integer
The maximum number of items to return.
set_locator_class($class = 'SimplePie_Locator'
)
set_max_checked_feeds(integer $max = 10
)
integer
Maximum number of feeds to check
set_output_encoding(string $encoding = 'UTF-8'
)
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 \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 http://simplepie.org/wiki/faq/Supported_Character_Encodings for more information.
string
set_parser_class($class = 'SimplePie_Parser'
)
set_raw_data(string $data)
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 |
---|---|
see |
string
RSS or Atom data as a string.
set_restriction_class($class = 'SimplePie_Restriction'
)
set_sanitize_class($class = 'SimplePie_Sanitize'
)
set_source_class($class = 'SimplePie_Source'
)
set_stupidly_fast(boolean $set = false
)
Forgoes a substantial amount of data sanitization in favor of speed. This turns SimplePie into a dumb parser of feeds.
boolean
Whether to set them or not
set_timeout(integer $timeout = 10
)
This allows you to change the maximum time the feed's server to respond and send the feed back.
since | 1.0 Beta 3 |
---|
integer
The maximum number of seconds to spend waiting to retrieve a feed.
set_url_replacements(array|null $element_attribute = null
)
Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite, |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite, |q|@cite
since | 1.0 |
---|
array
null
Element/attribute key/value pairs, null for default
set_useragent(string $ua = SIMPLEPIE_USERAGENT
)
string
New user agent string.
sort_items(\SimplePie $a, \SimplePie $b) : boolean
access | private |
---|
\SimplePie
\SimplePie
boolean
strip_attributes($attribs = ''
)
subscribe_url() : string | null
May or may not be different from the URL passed to \set_feed_url(), depending on whether auto-discovery was used.
since | Preview Release (previously called `get_feed_url()` since SimplePie 0.8.) |
---|---|
todo | If we have a perm redirect we should return the new URL |
todo | When we make the above change, let's support |
todo | Also, |atom:link|@rel=self |
string
null
fetch_data(\SimplePie_Cache|false $cache) : array | true
If the data is already cached, attempt to fetch it from there instead
\SimplePie_Cache
false
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$all_discovered_feeds : array
array()
$autodiscovery_cache_duration : integer
604800
$cache_location : string
'./cache'
$cache_name_function : string
'md5'
$config_settings : array
null
$data : array
array()
access | private |
---|
$error : mixed
access | private |
---|
$force_feed : boolean
false
$force_fsockopen : boolean
false
$image_handler : string
''
$input_encoding : mixed
false
$item_limit : integer
0
$max_checked_feeds : integer
10
$multifeed_objects : array
array()
access | private |
---|
$multifeed_url : array
array()
$registry : \SimplePie_Registry
$strip_attributes : array
array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')
strip_comments()
Parameters
$strip