public function actionIndex()
 {
     $pic = new Picasa();
     $account = $pic->getAlbumsByUsername($this->username);
     $albums = $account->getAlbums();
     //        var_dump($albums->getNumphotos());
     $album_newest = $pic->getAlbumById($this->username, $albums[0]->getIdnum(), null, null, null, null, null, 1000);
     $images_first_album_newest = $album_newest->getImages();
     //add meta tag fb
     Yii::app()->clientScript->registerMetaTag('Album ảnh của An An Cute', NULL, NULL, array('property' => 'og:title'));
     Yii::app()->clientScript->registerMetaTag('article', NULL, NULL, array('property' => 'og:type'));
     if (!empty($images_first_album_newest)) {
         Yii::app()->clientScript->registerMetaTag($images_first_album_newest[0]->getContent(), NULL, NULL, array('property' => 'og:image'));
     }
     Yii::app()->clientScript->registerMetaTag(Yii::app()->getRequest()->getHostInfo() . Yii::app()->request->requestUri, NULL, NULL, array('property' => 'og:url'));
     Yii::app()->clientScript->registerMetaTag('Trang web chia sẻ ảnh và video của An An Cute', NULL, NULL, array('property' => 'og:description'));
     $this->render('index', array('albums' => $albums));
 }
<?php

// load picasa lightweight library
require_once 'wp-esprit-picasa-library-include.php';
$picasa = new Picasa();
Picasa::setPicasaUrl($_REQUEST['server']);
$status = True;
try {
    $account = $picasa->getAlbumsByUsername($_REQUEST['username'], 0);
} catch (Exception $e) {
    $status = False;
}
if ($_REQUEST['type'] == 'rpc') {
    $xml = "<picasa>";
    $xml .= "<status>";
    if ($status) {
        $xml .= "OK";
    } else {
        $xml .= "ERROR";
    }
    $xml .= "</status>\n";
    $xml .= "</picasa>";
    header('Content-type: text/xml');
    echo $xml;
}
// how many photos we will display on each line
$albumsPerRow = 4;
// the size of the photo displayed in admin area
$albumThumbnailSize = "144";
$picasa = new Picasa();
Picasa::setPicasaUrl(get_option(WpEspritPicasa::$WP_OPTION_SERVER));
// get the album name from the request
$albumId = null;
if (isset($_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID])) {
    $albumId = $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID];
}
$tab = $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_TAB];
$html = "<div id=\"PicasaWrapper\">";
$i = 0;
if (is_null($albumId)) {
    $account = $picasa->getAlbumsByUsername(get_option(WpEspritPicasa::$WP_OPTION_USERNAME), null, null, null, $albumThumbnailSize . "c");
    foreach ($account->getAlbums() as $album) {
        $html .= $i % $albumsPerRow == 0 ? "<div class=\"row\">\n" : "";
        $html .= "  <div class=\"PicasaAlbums\">\n";
        $html .= "    <a href=\"" . $_SERVER["PHP_SELF"] . "?" . $uriParams . "&" . WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID . "=" . $album->getIdnum() . "\">\n";
        $html .= "      <img src=\"" . $album->getIcon() . "\" width=\"" . $albumThumbnailSize . "px\" height=\"" . $albumThumbnailSize . "px\">\n";
        $html .= "    </a>\n";
        $html .= "    <h5>" . $album->getTitle() . "</h5>\n";
        $html .= "    <p>" . WpEspritPicasa::gDate('D jS F Y', $album->getTimestamp()) . " (photos: " . $album->getNumphotos() . ")</p>\n";
        $html .= "  </div>\n";
        if (($i + 1) % $albumsPerRow == 0) {
            $html .= "</div>\n";
            $html .= "<div class='clear'><br></div>";
        }
        $i++;
    }
示例#4
0
require_once 'Picasa.php';
$username = "******";
?>
<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>An An cute</title>
    </head>
    <body>
        <?php 
//Account Page
//For the account page, the only thing you'll need is the username. I recommend storing the username in a constant variable somewhere where all your code can access. This is so that if your username changes, or you want to give your code to someone else, you only have to change the username in one place. I store mine in a variable called "Cam_Util_PictureUtil::$USERNAME". However, for the sake of readability, I'll just refer to it in the following code as "$username". Here's the code for the account page, which just outputs each album's icon with a link to the album page. I use a URL structure similar to what my site uses, but modified to be closer to the typical setup. And obviously you can change the HTML to suit your needs:
$pic = new Picasa();
//        Picasa_Logger::getLogger()->setEnabled(true);
$account = $pic->getAlbumsByUsername($username);
$albums = $account->getAlbums();
foreach ($albums as $album) {
    print '<a href="http://www.your_web_site.com/album.php?albumid=' . $album->getIdnum() . '"><img src="' . $album->getIcon() . '" />';
    print '<div>' . $album->getTitle() . '</div>';
}
//        Album Page
//For the album page, you'll not only need the username, but you'll also need the album id. If you use the URL structure used in the previous example, you should be able to get the album id from the $_GET superglobal. I'll include how to do that in the code sample. So the album page just prints each image in the album with a link to the Image Page and the album title displayed below:
//        $albumid = $_GET["albumid"];
//        $pic = new Picasa();
//        $album = $pic->getAlbumById($username, $albumid);
//        $images = $album->getImages();
//        foreach ($images as $image)
//        {
//            print('<a href="' . SITE_URL .'image.php?albumid=' . $albumid . '&imageid=' . $image->getIdnum() . '"><img src="' . $image->getLargeThumb() . '"/>');
//            print('<div>' . $image->getTitle() . '</div>');
		</a>
	</div>
';
            if ($row_count == $row_images) {
                echo '</div><hr>';
                $row_count = 0;
            }
        }
    } else {
        echo "<div class=\"alert alert-error\"><h2>Порошок — уходи! &nbsp;&nbsp;&nbsp;(<i class=\"icon-remove\"></i>__<i class=\"icon-remove\"></i>)</h2></div>";
        return false;
    }
} else {
    $modx->setPlaceholder('AlbumTitle', '<h2><small>Фотографии наших объектов со всех уголков России</small></h2>');
    $pic = new Picasa();
    $all_albums = $pic->getAlbumsByUsername($username);
    $albums = $all_albums->getAlbums();
    /*
        echo "<pre>";
        print_r ($albums);
        echo "</pre>";
    */
    $row_count = 0;
    foreach ($albums as $album) {
        if (in_array($album->getIdnum(), $exclude_gid)) {
            continue;
        } else {
            $row_count++;
            // иконка альбома
            $album_thumb['id'] = $album->getIdnum();
            $album_thumb['url'] = $album->getIcon();