/ Published in: PHP
URL: http://stocklamp.tumblr.com/post/274675902/putting-your-tumblr-posts-on-your-websites-the-easy-way
Embed Tumblr posts the easy way. Import the xml, split by post-type and seperate the different types of content. I had a hard time finding an easy way to do this and ended up mixing and matching info from 2 very helpful places (check the url\'s in the src) and a co-worker who\'s better versed in PHP than me.
Expand |
Embed | Plain Text
<?php //http://stocklamp.tumblr.com/post/274675902/putting-your-tumblr-posts-on-your-websites-the-easy-way //http://finlay.tumblr.com/post/529010691/embed-tumblr-into-your-website //http://www.tumblr.com/docs/en/api#api_read $xml = simplexml_load_file('http://webretailcompany.tumblr.com/api/read/xml?num=3'); $posts = $xml->xpath("/tumblr/posts/post"); foreach($posts as $post) { ?> <?php if ($post['type'] == 'regular') { ?> <?php } ?> <?php if ($post['type'] == 'conversation') { ?> <?php } ?> <div class="post-body"> <?php if ($post['type'] == 'regular') { <?php if ($post['type'] == 'quote') { ?> <?php } ?> <?php if ($post['type'] == 'photo') { ?> <?php } ?> <?php if ($post['type'] == 'link') { ?> <?php } ?> <?php if ($post['type'] == 'conversation') { ?> <?php } ?> <?php if ($post['type'] == 'video') { ?> <?php } ?> <?php if ($post['type'] == 'conversation') { ?> <?php } ?> </div><!-- //end post-body --> </div><!-- //end post--> <?php } ?>
Comments
Subscribe to comments
You need to login to post a comment.

Just what I was looking for, great stuff! Thank you for sharing
Thank you for sharing this little hidden gem. Why doesn't the photos or videos appear when they are being uploaded to Tumblr's server? It seems like photos or videos (eg. Youtube video) only appear... not the embedded ones. Any ideas?
Again, thank you for sharing!!!
Thank you for sharing this little hidden gem. Why doesn't the photos or videos appear when they are being uploaded to Tumblr's server? It seems like photos or videos (eg. Youtube video) only appear... not the embedded ones. Any ideas?
Again, thank you for sharing!!!
Thank you for sharing this little hidden gem. Why doesn't the photos or videos appear when they are being uploaded to Tumblr's server? It seems like photos or videos (eg. Youtube video) only appear... not the embedded ones. Any ideas?
Again, thank you for sharing!!!
Thank you for sharing this little hidden gem. Why doesn't the photos or videos appear when they are being uploaded to Tumblr's server? It seems like photos or videos (eg. Youtube video) only appear... not the embedded ones. Any ideas?
Again, thank you for sharing!!!
@gamma888: Hm, no idea. If it’s visible in tumblr, it should work after import as well. Haven’t come across the problem myself.
I can confirm that Tumblr photo URLs are not resolving properly, but I can't figure out why. One slightly messy solution that does work however, is to change
to
Meant to say changing the photo-url-500 to simply photo-url and putting it as an iframe src. It works, if not very elegantly.
Photo-url-500 can't seem to resolve the media link that Tumblr uses.
Maybe Rembrand can shed some like on this, but if I find a fix, I'll post back.