SimplePie: PHP-based RSS and Atom feed handling
 
  • Overview
  • Demo
  • Blog
  • Download
  • Documentation
  • API Docs
  • Support
  • Issue Tracker
  • FAQ
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • SimplePie
    • API
    • Caching
    • HTTP
    • Parsing

Classes

  • SimplePie
  • SimplePie_Author
  • SimplePie_Caption
  • SimplePie_Category
  • SimplePie_Copyright
  • SimplePie_Core
  • SimplePie_Credit
  • SimplePie_Enclosure
  • SimplePie_Item
  • SimplePie_Rating
  • SimplePie_Restriction
  • SimplePie_Source

Class SimplePie_Item

Manages all item-related data

Used by SimplePie::get_item() and SimplePie::get_items()

This class can be overloaded with SimplePie::set_item_class()

Package: SimplePie\API
Copyright: 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
License: BSD License
Author: Ryan Parman
Author: Geoffrey Sneddon
Author: Ryan McCue
Located at SimplePie/Item.php
Methods summary
public
# __construct( SimplePie $feed, array $data )

Create a new item object

This is usually used by SimplePie::get_items() and SimplePie::get_item(). Avoid creating this manually.

Parameters

$feed
SimplePie
Parent feed
$data
array
Raw data
public
# set_registry( SimplePie_Registry $registry )

Set the registry handler

This is usually used by SimplePie_Registry::create()

Parameters

$registry
SimplePie_Registry

Since

1.3
public string
# __toString( )

Get a string representation of the item

Returns

string
public
# __destruct( )

Remove items that link back to this before destroying this object

public array
# get_item_tags( string $namespace, string $tag )

Get data for an item-level element

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

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

Returns

array

Since

1.0

See

http://simplepie.org/wiki/faq/supported_xml_namespaces
public string
# get_base( array $element = array() )

Get the base URL value from the parent feed

Uses <xml:base>

Parameters

$element
array

Returns

string
public string
# sanitize( string $data, integer $type, string $base = '' )

Sanitize feed data

Parameters

$data
string
Data to sanitize
$type
integer
One of the SIMPLEPIE_CONSTRUCT_* constants
$base
string
Base URL to resolve URLs against

Returns

string
Sanitized data

See

SimplePie::sanitize()
public SimplePie
# get_feed( )

Get the parent feed

Note: this may not work as you think for multifeeds!

Returns

SimplePie

Since

1.0

Link

http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
public string
# get_id( boolean $hash = false )

Get the unique identifier for the item

This is usually used when writing code to check for new items in a feed.

Uses <atom:id>, <guid>, <dc:identifier> or the about attribute for RDF. If none of these are supplied (or $hash is true), creates an MD5 hash based on the permalink and title. If either of those are not supplied, creates a hash based on the full feed data.

Parameters

$hash
boolean
Should we force using a hash instead of the supplied ID?

Returns

string

Since

Beta 2
public string|null
# get_title( )

Get the title of the item

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

Returns

string|null

Since

Beta 2 (previously called get_item_title since 0.8)
public string|null
# get_description( boolean $description_only = false )

Get the content for the item

Prefers summaries over full content , but will return full content if a summary does not exist.

To prefer full content instead, use SimplePie_Item::get_content()

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

Parameters

$description_only
boolean
Should we avoid falling back to the content?

Returns

string|null

Since

0.8
public string|null
# get_content( boolean $content_only = false )

Get the content for the item

Prefers full content over summaries, but will return a summary if full content does not exist.

To prefer summaries instead, use SimplePie_Item::get_description()

Uses <atom:content> or <content:encoded> (RSS 1.0 Content Module)

Parameters

$content_only
boolean
Should we avoid falling back to the description?

Returns

string|null

Since

1.0
public SimplePie_Category|null
# get_category( integer $key = 0 )

Get a category for the item

Parameters

$key
integer
The category that you want to return. Remember that arrays begin with 0, not 1

Returns

SimplePie_Category|null

Since

Beta 3 (previously called get_categories() since Beta 2)
public array|null
# get_categories( )

Get all categories for the item

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

Returns

array|null
List of SimplePie_Category objects

Since

Beta 3
public SimplePie_Author|null
# get_author( integer $key = 0 )

Get an author for the item

Parameters

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

Returns

SimplePie_Author|null

Since

Beta 2
public SimplePie_Author|null
# get_contributor( integer $key = 0 )

Get a contributor for the item

Parameters

$key
integer
The contrbutor that you want to return. Remember that arrays begin with 0, not 1

Returns

SimplePie_Author|null

Since

1.1
public array|null
# get_contributors( )

Get all contributors for the item

Uses <atom:contributor>

Returns

array|null
List of SimplePie_Author objects

Since

1.1
public array|null
# get_authors( )

Get all authors for the item

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

Returns

array|null
List of SimplePie_Author objects

Since

Beta 2
public string
# get_copyright( )

Get the copyright info for the item

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

Returns

string

Since

1.1
public integer|string|null
# get_date( string $date_format = 'j F Y, g:i a' )

Get the posting date/time for the item

Uses <atom:published>, <atom:updated>, <atom:issued>, <atom:modified>, <pubDate> or <dc:date>

Note: obeys PHP's timezone setting. To get a UTC date/time, use SimplePie_Item::get_gmdate()

Parameters

$date_format
string
Supports any PHP date format from http://php.net/date (empty for the raw data)

Returns

integer|string|null

Since

Beta 2 (previously called get_item_date since 0.8)
public integer|string|null
# get_updated_date( string $date_format = 'j F Y, g:i a' )

Get the update date/time for the item

Uses <atom:updated>

Note: obeys PHP's timezone setting. To get a UTC date/time, use SimplePie_Item::get_gmdate()

Parameters

$date_format
string
Supports any PHP date format from http://php.net/date (empty for the raw data)

Returns

integer|string|null
public integer|string|null
# get_local_date( string $date_format = '%c' )

Get the localized posting date/time for the item

Returns the date formatted in the localized language. To display in languages other than the server's default, you need to change the locale with setlocale(). The available localizations depend on which ones are installed on your web server.

Parameters

$date_format
string
Supports any PHP date format from http://php.net/strftime (empty for the raw data)

Returns

integer|string|null

Since

1.0
public integer|string|null
# get_gmdate( string $date_format = 'j F Y, g:i a' )

Get the posting date/time for the item (UTC time)

Parameters

$date_format
string
Supports any PHP date format from http://php.net/date

Returns

integer|string|null

See

SimplePie_Item::get_date()
public integer|string|null
# get_updated_gmdate( string $date_format = 'j F Y, g:i a' )

Get the update date/time for the item (UTC time)

Parameters

$date_format
string
Supports any PHP date format from http://php.net/date

Returns

integer|string|null

See

SimplePie_Item::get_updated_date()
public string|null
# get_permalink( )

Get the permalink for the item

Returns the first link available with a relationship of "alternate". Identical to SimplePie_Item::get_link() with key 0

Returns

string|null
Permalink URL

Since

0.8

See

SimplePie_Item::get_link()
public string|null
# get_link( integer $key = 0, string $rel = 'alternate' )

Get a single link for the item

Parameters

$key
integer
The link that you want to return. Remember that arrays begin with 0, not 1
$rel
string
The relationship of the link to return

Returns

string|null
Link URL

Since

Beta 3
public array|null
# get_links( string $rel = 'alternate' )

Get all links for the item

Uses <atom:link>, <link> or <guid>

Parameters

$rel
string
The relationship of links to return

Returns

array|null
Links found for the item (strings)

Since

Beta 2
public SimplePie_Enclosure|null
# get_enclosure( integer $key = 0, $prefer = null )

Get an enclosure from the item

Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.

Parameters

$key
integer
The enclosure that you want to return. Remember that arrays begin with 0, not 1
$prefer

Returns

SimplePie_Enclosure|null

Since

Beta 2
public array|null
# get_enclosures( )

Get all available enclosures (podcasts, etc.)

Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.

At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support.

Returns

array|null
List of SimplePie_Enclosure items

Since

Beta 2
public string|null
# 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>

Returns

string|null

Since

1.0

Link

W3C WGS84 Basic Geo
GeoRSS
public string|null
# get_longitude( )

Get the longitude coordinates for the item

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

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

Returns

string|null

Since

1.0

Link

W3C WGS84 Basic Geo
GeoRSS
public SimplePie_Source|null
# get_source( )

Get the <atom:source> for the item

Returns

SimplePie_Source|null

Since

1.1
Properties summary
public SimplePie $feed
#

Parent feed

public array $data array()
#

Raw data

protected SimplePie_Registry $registry
#

Registry object

See

SimplePie_Item::set_registry()

Show some love! Wishlists for Geoffrey, Ryan P., and Ryan M.

SimplePie is © 2004–2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue and contributors. Licensed under the BSD License. Hosted thanks to Matt Mullenweg, API documentation generated by ApiGen 2.6.1. Variation on the Feed Icon by Wolfgang Bartelme.