SimplePie and Digg’s RSS Feeds

Been playing with SimplePie some more and here is some code for dealing with Digg’s RSS feed. I included some stuff in comments that just shows how their namespaces look.

<digg:category>Political News</digg:category>
$digg_count = $item->get_item_tags('', 'diggCount');
$digg_comments = $item->get_item_tags('', 'commentCount');
$digg_category = $item->get_item_tags('', 'category');
$digg_submitter = $item->get_item_tags('', 'submitter');
$digg_username = $digg_submitter[0]['child']['']['username'];
$digg_userimage = $digg_submitter[0]['child']['']['userimage'];
if (!empty($digg_count[0]['data']))
$data .= '<br /><span class="minor">' . $digg_count[0]['data'] . ' diggs &middot; ' . $digg_comments[0]['data'] . ' comments &middot; ' . $digg_category[0]['data'] . ' &middot; ' . $digg_username[0]['data'] . ' &middot; ' . $digg_userimage[0]['data'] . '</span>';

Using something like the following helps traverse the arrays to figure out how to get the data.

print_r($digg_submitter);//will show array to parse to get stuff

Tags: , ,

Leave a Comment

Comments are reviewed before publishing to prevent spam.