/ Published in: PHP
Tumblr API: http://www.tumblr.com/docs/de/api
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $posts = $jsondata['posts']; $blogroll = ""; foreach($posts as $post){ $blogroll .= "<p>"; $blogroll .= $date."<br />"; switch ($post['type']) { case 'photo': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".str_replace('-',' ',$post['slug'])."</a>"; break; case 'link': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".$post['link-text']."</a><br />"; break; case 'regular': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".$post['regular-title']."</a><br />"; break; case 'quote': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".str_replace('-',' ',$post['slug'])."</a><br />"; break; case 'conversation': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".str_replace('-',' ',$post['slug'])."</a><br />"; }else{ $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".$post['conversation-title']."</a><br />"; } break; case 'audio': $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".str_replace('-',' ',$post['slug'])."</a><br />"; }else{ $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".strip_tags($post['audio-caption'])."</a><br />"; } break; default: $blogroll .= "<a href='".$post['url-with-slug']."' target='_blank'>".str_replace('-',' ',$post['slug'])."</a>"; break; } $blogroll .= "</p>"; } echo $blogroll; ?>