Jump to content

Recommended Posts

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 = "

$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;

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/273880-specific-photo-size-in-tumblr-api/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.