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:diggCount>95</digg:diggCount>
<digg:submitter>
<digg:username>kilooneniner</digg:username>
<digg:userimage>http://digg.com/userimages/k/i/l/kilooneniner/medium9515.jpg</digg:userimage>
</digg:submitter>
<digg:category>Political News</digg:category>
<digg:commentCount>9</digg:commentCount>
*/
//DIGG NAMESPACES
$digg_count = $item->get_item_tags('http://digg.com/docs/diggrss/', 'diggCount');
$digg_comments = $item->get_item_tags('http://digg.com/docs/diggrss/', 'commentCount');
$digg_category = $item->get_item_tags('http://digg.com/docs/diggrss/', 'category');
$digg_submitter = $item->get_item_tags('http://digg.com/docs/diggrss/', 'submitter');
$digg_username = $digg_submitter[0]['child']['http://digg.com/docs/diggrss/']['username'];
$digg_userimage = $digg_submitter[0]['child']['http://digg.com/docs/diggrss/']['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.