You are here: Documentation » API Reference » SimplePie_Item » get_id()
Table of Contents
get_id()
Description
class SimplePie_Item { get_id ( [(bool) $hash = false] ) }
Returns the unique identifier for the posting. This is most helpful in writing code to check for new items in a feed.
Availability
- Available since SimplePie Beta 2.
Parameters
hash
If set to true, SimplePie will return a unique MD5 hash for the item. If set to false, it will check <guid>
, <link>
, and <title>
before defaulting to the hash.
Examples
Checking the ID of the posting against a list
$feed = new SimplePie(); $feed->set_feed_url('http://simplepie.org/blog/feed/'); $feed->init(); $feed->handle_content_type(); foreach ($feed->get_items() as $item) { $prev_ids = array('guid1', 'guid2', 'guid3', 'guid4'); if (in_array($item->get_id(true), $prev_ids)) { echo "This item is already stored."; } else { echo "This is a new item!"; } }
See Also
reference/simplepie_item/get_id.txt · Last modified: 2011/03/06 03:56 (external edit)