function getData($data,$startTag,$finishTag){
$data= explode($startTag,$data);
$data= $data[1];
$data= explode($finishTag,$data);
$data= $data[0];
return $data;
}
$sayfa ='tumblrsayfaismi';
$sayfa =htmlspecialchars($sayfa,ENT_QUOTES);
$total_bul = file_get_contents('https://'.$sayfa.'.tumblr.com/api/read?type=photo');
$total_sayi= getData($total_bul,'<posts type="photo" start="0" total="','">');
if ($total_sayi>=3) { $total_sayi=3;}
for($sayi = 0; $sayi < $total_sayi; $sayi++) {
$myXMLData=file_get_contents("https://".$sayfa.".tumblr.com/api/read?type=photo&num=1&start=".$sayi."");
$xml=simplexml_load_string($myXMLData) or die("Error: Cannot create object");
$xml = new XMLReader();
$xml->XML($myXMLData);
while( $xml->read() ) {
if($xml->name == 'photo-url') {
$resim = $xml->getAttribute('photo-url');
$resim = $xml->readInnerXML();
if (!empty($resim))
{
echo '<img src="'.$resim.'" width="150px" height="150px">';
}
$xml->next();
}
}
Yorumlar