<?php
function getRSS( $url ){
$cobj = curl_init( $url );
curl_setopt( $cobj, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $cobj, CURLOPT_CONNECTTIMEOUT, 0 );//0 = no timeout
$tumblr_raw = curl_exec( $cobj );
curl_close( $cobj );
if( $tumblr_raw ){
$tumblr_xml = new DOMDocument();
$tumblr_xml->loadXML( $tumblr_raw );
//echo( "<pre>".$tumblr_xml->saveHTML()."</pre>" );
if( $tumblr_xml->getElementsByTagName("item") instanceof DOMNodeList &&
$tumblr_xml->getElementsByTagName("item")->item(0) instanceof DOMElement &&
$tumblr_xml->getElementsByTagName("item")->item(0)->hasChildNodes() ){
foreach( $tumblr_xml->getElementsByTagName("item") as $tweet ){
foreach( $tweet->childNodes as $deetz ){
if( $deetz->nodeType == 1 && $deetz->nodeName == "title" )
$tweet_title = $deetz->textContent;
elseif( $deetz->nodeType == 1 && $deetz->nodeName == "pubDate" )
$tweet_date = $deetz->textContent;
elseif( $deetz->nodeType == 1 && $deetz->nodeName == "guid" )
$tweet_url = $deetz->textContent;
elseif( $deetz->nodeType == 1 && $deetz->nodeName == "description" )
$tumbl_img = $deetz->textContent;
}
$tweetz[] = Array( "title" => $tweet_title,
"date" => $tweet_date,
"url" => $tweet_url,
"img" => $tumbl_img );
}
}
else return "Tumblr is broken";
}
else return "Tumblr is broken";
return $tweetz;
}
if( $tumblr = getRSS("http://ominousss.tumblr.com/rss") ){
echo( "<section id=\"recent-tumbls\">\n" );
echo( "<div><ul>\n" );
//echo("<pre>\n");print_r( $tumblr );echo("</pre>\n");
for( $i=0; $i < 9; $i++ ){
if( isset($tumblr[$i]) ){
echo( "<li>\n" );
echo( "<a href=\"".$tumblr[$i]["url"]."\" rel=\"external\">\n" );
echo( "<span class=\"tumblr_title\">".$tumblr[$i]["title"]."</span>\n" );
echo( "<span class=\"tumblr_date\">\n" );
echo( substr($tumblr[$i]["date"],0,strlen($tumblr[$i]["date"])-6) );
echo( "</span>\n" );
echo( "<span class=\"imgry\">" . $tumblr[$i]["img"] . "</span>\n" );
echo( "</a>\n" );
echo( "</li>\n" );
}
}
echo( "</ul></div>\n" );
echo( "<a href=\"http://ominousss.tumblr.com\" rel=\"external\" title=\"Tumblr page\">Tumblr</a>\n" );
echo( "</section>\n\n" );
}
?>