rumeye Posted January 31, 2013 Share Posted January 31, 2013 I am trying to include the latest post from a tumblr blog in my website, which works fine. I can't figure out how to choose a specific size of photo from the API, such as the 500px photo. <?php $numPosts = 3; $feedURL = "http://jeffhui.tumblr.com/api/read/?num=$numPosts"; $xml = simplexml_load_file($feedURL); foreach($xml->posts->post as $post){ $title = (string) $post->{'regular-title'}; $posts = (string) $post->{'regular-body'}; $photo = (string) $post->{'photo-url'}; $caption = (string) $post->{'photo-caption'}; echo"<h2>".$title."</h2> <p>".$posts."</p> <p><img src=".$photo."></p> <p>".$caption."</p>"; } ?> Some one posted this online and say it has to loop through them like this, but I dont know how to apply the bellow script into my. <?php $xmlResult = file_get_contents($tumblr_url_aktuell); $xml = simplexml_load_file($tumblr_url_aktuell); foreach($xml->posts->post->{'photo-url'} as $photoURL){ if((string)$photoURL['max-width'] == '500'){ $image = $photoURL; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/273880-specific-photo-size-in-tumblr-api/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.