<?php

require_once '../assets/api/phpflickr/phpFlickr.php';
$f = new phpFlickr("######", "######", false);
$recent = $f->photos_getSizes("20321869573");
var_dump($recent);
Esempio n. 2
0
foreach ($photos['photo'] as $photo) {
    //Console Log image message counter
    echo "Image: " . $imageCounter++ . " / ";
    //We get the Information of each photo giving the Photo_ID
    $photo_info = $flickrObject->photos_getInfo($photo['id']);
    echo $photo["id"] . ' - ';
    if (in_array($photo['id'], $idArrayImages)) {
        echo "Hay una imagen repetida";
    }
    $idArrayImages[] = $photo['id'];
    //Uncomment this line to see the PUBLIC URL of the photo
    //echo $photo_info['photo']['urls']['url'][0]['_content']."\n";
    //We stract the TAGS array for each photo
    $array_tags = $photo_info['photo']['tags']['tag'];
    //Get the different sizes of the image
    $photo_sizes = $flickrObject->photos_getSizes($photo['id']);
    //We look the optimal size
    foreach ($photo_sizes as $size) {
        //Only get Medium Images for file sizes proposes
        if ($size['label'] == 'Medium 640') {
            $url = $size['source'];
        }
    }
    $line = $url . ":";
    //Uncomment this to see in the browser the image in thumbnail size
    //echo '<img alt="'.$photo['title'].'" src="'.$flickrObject->buildPhotoURL($photo, "square").'" />';
    //Uncomment this line to see in the browser the link of the URL
    //echo '<a rel="nofollow" target="_blank" href="'.$url.'">Link : </a>';
    //Create the line with all the good tags
    //Initialize the clean line
    $tags_line = '';
Esempio n. 3
0
?>
		<header>
			<h1>Resultados de la b&uacute;squeda: Total [<?php 
echo $total;
?>
] pagina: <?php 
echo $page;
?>
</h1>
		</header>
		<section>
			<article id="galeria">
				<ul>
				<?php 
foreach ($recent['photo'] as $photo) {
    $tamanos = $f->photos_getSizes($photo['id']);
    $folder = $photo['server'];
    $label = "";
    $fuente = "";
    $fuentethw = "150px";
    $fuentethh = "150px";
    $num = count($tamanos);
    foreach ($tamanos as $tmns) {
        $label = $tmns['label'];
        $fuente = $tmns['source'];
        if ($label == 'Thumbnail') {
            $fuenteth = $tmns['source'];
            $fuentethw = $tmns['width'];
            $fuentethh = $tmns['height'];
        }
    }
Esempio n. 4
0
// === S T E P 4 ===
// Run the script via the command line using: "php download-all.php"
// Connect to Flickr
$f = new phpFlickr(API_KEY, API_SECRET, true);
$f->setToken(API_TOKEN);
// Get all of our photosets
$sets = $f->photosets_getList(UID);
foreach ($sets['photoset'] as $set) {
    echo "### " . $set['title'] . "\n";
    @mkdir("photos/{$set['title']}", 0777, true);
    // Get all the photos in this set
    $photos = $f->photosets_getPhotos($set['id']);
    // And download each one...
    foreach ($photos['photoset']['photo'] as $photo) {
        $url = null;
        $sizes = $f->photos_getSizes($photo['id']);
        foreach ($sizes as $size) {
            if ($size['label'] == 'Original') {
                $url = $size['source'];
            }
        }
        if (!is_null($url)) {
            $dir = escapeshellarg("photos/{$set['title']}");
            $filename = parse_url($url, PHP_URL_PATH);
            // Only download if file does not exist...
            if (!file_exists("photos/{$set['title']}/{$filename}")) {
                shell_exec("cd {$dir}; /usr/bin/curl -O {$url}");
            }
        }
        // This helps stop the Flickr API from getting angry
        sleep(1);
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title');
     $username = $this->get_config('email');
     $num = $this->get_config('perpage');
     $choices = $this->get_config('numberOfChoices');
     //added 110730 by artodeto
     $useChoices = $this->get_config('useChoices');
     //added 110730 by artodeto
     $apiKey = $this->get_config('apikey');
     $apiSecret = $this->get_config('apisecret');
     $sourceimgtype = $this->get_config('sourceimgtype');
     $targetimgtype = $this->get_config('targetimgtype');
     $errors = array();
     /* 		Get image data from flickr */
     $f = new phpFlickr($apiKey, $apiSecret);
     $f->enableCache("fs", $serendipity['serendipityPath'] . 'templates_c/', $this->get_config('cachetimeout'));
     if (stristr($username, '@')) {
         $nsid = $f->people_findByEmail($username);
     } else {
         $nsid = $f->people_findByUsername($username);
     }
     if ($nsid === false) {
         $errors[] = PLUGIN_SIDEBAR_FLICKR_ERROR_WRONGUSER;
     }
     /* Can't find user */
     $photos_url = $f->urls_getUserPhotos($nsid['nsid']);
     if ($useChoices === true) {
         $photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $choices, "sort" => "date-posted-desc", "extras" => "date_taken"));
     } else {
         $photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $num, "sort" => "date-posted-desc", "extras" => "date_taken"));
     }
     if ($photos[total] > 0 && $f) {
         $sizelist = array("0" => "Square", "1" => "Thumbnail", "2" => "Small", "3" => "Medium", "4" => "Large", "5" => "Original");
         if ($useChoices === true) {
             //added 110730 by artodeto
             shuffle($photos['photo']);
             array_splice($photos['photo'], $num);
         }
         foreach ($photos['photo'] as $photo) {
             if ($photo['ispublic'] !== 1) {
                 continue;
             }
             $imgdate = strftime("%d.%m.%y %H:%M", strtotime($photo['datetaken']));
             $imgtitle = $photo['title'];
             /* 				Choose available image size */
             $sizes_available = $f->photos_getSizes($photo[id]);
             $photosize = $sourceimgtype;
             $imgsrcdata = NULL;
             while ($imgsrcdata == NULL && $photosize >= 0) {
                 $imgsrcdata = getsizedata($sizes_available, $sizelist[$photosize]);
                 $photosize--;
             }
             /* If updating from previous versions, $targetimgtype could be -1. So we set it to the next legal value 2. */
             $photosize = max($targetimgtype, 2);
             $imgtrgdata = NULL;
             while ($imgtrgdata == NULL && $photosize >= 0) {
                 $imgtrgdata = getsizedata($sizes_available, $sizelist[$photosize]);
                 $photosize--;
             }
             $img_width = $imgsrcdata['width'];
             $img_height = $imgsrcdata['height'];
             $img_url = $imgsrcdata['source'];
             if ($this->get_config('targetlink') == "JPG") {
                 $link_url = $imgtrgdata['source'];
             } else {
                 $link_url = $imgtrgdata['url'];
             }
             if ($this->get_config('showdate') || $this->get_config('showtitle')) {
                 unset($info);
                 if ($this->get_config('showdate')) {
                     $info .= '<span class="serendipity_plugin_flickr_date">' . $imgdate . '</span>';
                 }
                 if ($this->get_config('showtitle')) {
                     $info .= '<span class="serendipity_plugin_flickr_title">' . $imgtitle . '</span>';
                 }
                 if ($this->get_config('lightbox') != '') {
                     $lightbox = 'rel="' . $this->get_config('lightbox') . '" ';
                 }
                 $images .= sprintf('<dd style="width:%spx;"><a %shref="%s" ><img src="%s" width="%s" height="%s" title="%s" alt="%s"/></a></dd><dt style="width:%spx;margin-left:-%spx;">%s</dt>' . "\n", $img_width, $lightbox, $link_url, $img_url, $img_width, $img_height, $photo[title], $photo[title], $img_width, $img_width + 5, $info);
             } else {
                 $images .= sprintf('<dd style="width:%spx;"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s"/></a></dd>' . "\n", $img_width, $link_url, $img_url, $img_width, $img_height, $photo[title]);
             }
             $i++;
         }
     } else {
         $errors[] = PLUGIN_SIDEBAR_FLICKR_ERROR_NOIMG;
         /* No images available */
     }
     $content = '<dl class="serendipity_plugin_flickr">' . "\n";
     $content .= "\n" . $images;
     $content .= '</dl>';
     $footer = array();
     if ($this->get_config('showrss')) {
         $rssicon = serendipity_getTemplateFile('img/xml.gif');
         $footer[] = '<a class="serendipity_xml_icon" href="http://api.flickr.com/services/feeds/photos_public.gne?id=' . $nsid['nsid'] . '&amp;format=rss_200"><img src="' . $rssicon . '" alt="XML" style="border: 0px" /></a>' . "\n" . '<a href="http://api.flickr.com/services/feeds/photos_public.gne?id=' . $nsid['nsid'] . '&amp;format=rss_200">' . PLUGIN_SIDEBAR_FLICKR_LINK_SHOWRSS . '</a>';
     }
     if ($this->get_config('showphotostream')) {
         $footer[] = '<a href="http://www.flickr.com/photos/' . $username . '/">' . PLUGIN_SIDEBAR_FLICKR_LINK_PHOTOSTREAM . '</a>';
     }
     if (count($footer) > 0) {
         $content .= '<p class="serendipity_plugin_flickr_links">';
         $content .= join("<br />\n", $footer) . "\n";
         $content .= '</p>';
     }
     if (count($errors) > 0) {
         $content .= '<p class="serendipity_plugin_flickr_errors">';
         $content .= join("<br />\n", $errors) . "\n";
         $content .= '</p>';
     }
     echo $content;
 }