Home :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes 18.188.252.23
cf http://infosthetics.com/archives/2006/02/flickrmixr_xml_rss_feed_visualization.html

code source pour une image :

<?php
/*
mixr160.php
genere une image à partir d'un appel URI  type : mixr160.php?tag=test
*/
if($_GET['tag']) {
    if( 
preg_match("/^[a-zA-Z0-9]*$/"$_GET['tag']) ) {
        
$tag $_GET['tag'];
    } else {
        
$tag "vacation";
    }
} else {
    
$tag "vacation";
}

$im_w       160;          //largeur image
$im_h       80;          //hauteur image
$im imagecreatetruecolor($im_w $im_h );
$bgc imagecolorallocate($im000);
$tc  imagecolorallocate($im255255255);
imagefilledrectangle($im00$im_w $im_h $bgc);
$ty 5;
 
//$ty += 10;

$store FALSE;
$cur_tag "";
$cur_data "";
$n 0;
$error "";

$cur_item = array('titre'=>'''url'=>'''contenu'=>'','dat'=>'');

function 
startElement($parser$name$attribs) {
     global 
$cur_tag$cur_data$cur_item$store$n$tc$im$im_w$im_h$ty;

     if(
$name == "MEDIA:THUMBNAIL" && $n<5) {

        
$url $attribs['URL'];
        
$ws $attribs['WIDTH'];
        
$hs $attribs['HEIGHT'];
        
        
//if($ws<=640 && $hs<=480) {
            
if($ims = @imagecreatefromjpeg($url)) {
                
$imtemp imagecreatetruecolor($im_w $im_h );
                
imagecopyresampled ($imtemp$ims0000$im_w$im_h$ws$hs);
                
imagecopymerge$im$imtemp0000$im_w$im_h50);//$im_w
                
$n++;
                
imagedestroy($imtemp);
                
imagedestroy($ims);
            } else {
                
//imagestring($im, 1, 5, $ty, "Error loading $url", $tc); 
                //$ty +=10;
            
}
        
//} else {
            //imagestring($im, 1, 5, $ty, "$ws $hs", $tc); 
            //$ty += 10;
        //}

     
}

}


function 
endElement($parser$name) {
    global 
$cur_item$store;

}


function 
characterData ($parser$data) {
    global 
$cur_tag$cur_item$store;

}



$xml_file "http://www.flickr.com/services/feeds/photos_public.gne?tags=".$_GET['tag']."&format=rss_200";

$encoding "UTF-8";
if(
$fp fopen($xml_file"r")) {
    
//echo "<a href=\"$xml_file\">RSS</a><br />";
    
$xml_parser xml_parser_create("UTF-8");
    
xml_set_element_handler($xml_parser'startElement','endElement');
    
xml_set_character_data_handler($xml_parser'characterData');
    while (
$data fread($fp4096)) {
        if(
$encoding == "UTF-8") {
            
//$data = utf8_decode($data);
        
}
        if(!
xml_parse($xml_parser$dataFALSE)) {
            
$e xml_get_error_code $xml_parser );
            
$error .= xml_error_string($e)."<br>";
        }
    }
    
fclose($fp);
    
xml_parser_free ($xml_parser);
} else {
    
$error .= " erreur";
}
if(
$error == "") {
$s1 "DATAPAINTING@FLICKR ";
$s2 strtoupper($tag);///." - " . date("Y-m-d H:i:s"). "";
//imagestring($im, 1, 1, 1, $s1, $tc);
imagestring($im1470$s2$tc);
Header("Content-type: image/jpeg");
imagejpeg($im,'',100);
} else {
echo 
$error;
}
imagedestroy($im);
?>

Ajouter un commentaire à cette page: