function fwp_feedcontents() { $feed_id = MyPHP::request('feed_id'); // Let's load up some data from the feed . . . $feed = $this->subscription($feed_id); $posts = $feed->live_posts(); if (is_wp_error($posts)) { header("HTTP/1.1 502 Bad Gateway"); $result = $posts; } else { $result = array(); foreach ($posts as $post) { $p = new SyndicatedPost($post, $feed); $result[] = array("post_title" => $p->entry->get_title(), "post_link" => $p->permalink(), "guid" => $p->guid(), "post_date" => $p->published()); } } header("Content-Type: application/json"); echo json_encode($result); // This is an AJAX request, so close it out thus. die; }