/ Published in: PHP
Tumblr API: http://www.tumblr.com/docs/de/api
Expand |
Embed | Plain Text
<?php $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,"http://demo.tumblr.com/api/read/json"); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $result = curl_exec($ch); curl_close($ch); $jsondata = json_decode($result,true); $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; ?>
You need to login to post a comment.
