Php 在tumblr API中选择照片大小
我想把tumblr博客上的最新帖子放在我的网站上,效果很好。不过,我不知道如何从API中选择特定的标记 XML具有以下结构:Php 在tumblr API中选择照片大小,php,xml,api,tumblr,Php,Xml,Api,Tumblr,我想把tumblr博客上的最新帖子放在我的网站上,效果很好。不过,我不知道如何从API中选择特定的标记 XML具有以下结构: <tumblr> <posts> <post> <photo-url max-width="500"> image_500.jpg </photo-url> <photo-url
<tumblr>
<posts>
<post>
<photo-url max-width="500">
image_500.jpg
</photo-url>
<photo-url max-width="250">
image_250.jpg
</photo-url>
</post>
</posts>
</tumblr>
image_500.jpg
image_250.jpg
现在,我如何在第三行中指定我想要的250版本
<?php
$xmlResult = file_get_contents($tumblr_url_aktuell);
$xml = simplexml_load_file($tumblr_url_aktuell);
$image = $xml->posts->post->{'photo-url'}
?>
posts->post->{'photo-url'}
?>
谢谢大家! 您必须在它们之间循环以选择您想要的一个
<?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'] == '250'){
$image = $photoURL;
}
}
?>
posts->post->{'photo-url'}作为$photoURL){
如果((字符串)$photoURL['max-width']=='250'){
$image=$photoURL;
}
}
?>