Jump to content

Specific photo size in tumblr API


rumeye

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.