Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I stumbled across your question looking for something else about simplepie. But I do work with an identifier while using simplepie. So this seems to be the answer to your question:</p> <p>My getFeedPosts-function in PHP looks like this:</p> <pre><code>public function getFeedPosts($numberPosts = null) { $feed = new SimplePie(); // default options $feed-&gt;set_feed_url('http://yourname.blogspot.com'); // Set the feed $feed-&gt;enable_cache(true); /* Enable caching */ $feed-&gt;set_cache_duration(1800); /* seconds to cache the feed */ $feed-&gt;init(); // Run SimplePie. $feed-&gt;handle_content_type(); $allFeeds = array(); $number = $numberPosts&gt;0 ? $numberPosts : 0; foreach ($feed-&gt;get_items(0, $number) as $item) { $singleFeed = array( 'author'=&gt;$item-&gt;get_author(), 'categories'=&gt;$item-&gt;get_categories(), 'copyright'=&gt;$item-&gt;get_copyright(), 'content'=&gt;$item-&gt;get_content(), 'date'=&gt;$item-&gt;get_date("d.m.Y H:i"), 'description'=&gt;$item-&gt;get_description(), 'id'=&gt;$item-&gt;get_id(), 'latitude'=&gt;$item-&gt;get_latitude(), 'longitude'=&gt;$item-&gt;get_longitude(), 'permalink'=&gt;$item-&gt;get_permalink(), 'title'=&gt;$item-&gt;get_title() ); array_push($allFeeds, $singleFeed); } $feed = null; return json_encode($allFeeds); } </code></pre> <p>As you can see, I build a associative array and return it as JSON what makes it really easy using jQuery and ajax (in my case) on the client side.</p> <p>The 'id' is a unique identifier of every post in my blog. So this is the key to identify the same post also in another function/on another page. You just have to iterate the posts and compare this id. As far as I can see, there is no get_item($ID)-function. There is an get_item($key)-function but it is also just taking out a specific post from the list of all posts by the array-position (which is nearly the same way I suggest).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload