Flickr的API phpflickr [英] flickr phpflickr api

查看:164
本文介绍了Flickr的API phpflickr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

概述结果
我试图让使用Flickr的API和库phpflickr我的网站的照片供稿。我可以成功地得到我的网站的photoset,但它显示了所有从每photoset的照片,我希望能实现是为了显示各photoset主照片,然后当用户在图片上点击它会表现出全photoset在灯箱/太极拳。

Overview
I am trying to get a photo feed on to my site using Flickr's api and the phpflickr library. I can successfully get the photoset on to my site, but it shows all the photos from every photoset, what I was hoping to achieve was to show the primary photo from each photoset, and then if the user clicked on the image it would show the full photoset in a lightbox/shadowbox.

我的code

<div id="images" class="tabnav">
                    <ul class="items">
                        <?php $count = 1; ?>
                        <?php foreach ($photosets['photoset'] as $ph_set): ?>
                        <?php $parentID = $ph_set['parent']; ?>
                          <?php $photoset_id = $ph_set['id'];
                          $photos = $f->photosets_getPhotos($photoset_id);
                          foreach ($photos['photoset']['photo'] as $photo): ?>
                           <li>
                           <a rel="shadowbox['<?=$count;?>']" href="<?= $f->buildPhotoURL($photo, 'medium') ?>" title="<?= $photo['title'] ?>">
                                <img src="<?= $f->buildPhotoURL($photo, 'rectangle') ?>" alt="<?= $photo['title'] ?>" width="210" height="160" title="<?= $photo['title'] ?>" />
                                <h3><?=$ph_set['title']?></h3>
                                <p><?=$ph_set['description'];?></p>
                                </a>
                            </li>
                          <?php endforeach; ?>
                        <?php $count++; ?>
                        <?php endforeach; ?>
                    </ul>
                </div>

的又一次尝试

我也试图调用getPhotos功能不同,而不是发送它不带任何参数我把它带参数

I have also tried calling the getPhotos function differently, instead of sending it without any parameters I sent it with parameters

$photos = $f->photosets_getPhotos($photoset_id, NULL, NULL, 1, NULL);

以上code停止从每个photoset的显示所有的照片,开始只显示主图像,但它也停止了照片入店剩下我了。

The above code stopped the showing all the photos from each photoset and started showing just the primary image, but it also stopped making the rest of the photos accesible to me.

有什么我可以做,使这项工作?我完全失去了法语国家国际组织的想法。

Is there something I can do to make this work? I am totally out iof ideas.

问候和感谢

推荐答案

什么你可能会想要做的就是通过整个数组进行迭代和第一组每一张专辑到一个单独的阵列,使一个特殊的数组为你的专辑的首发主要的照片。

What you'll probably want to do is starting by iterating through the whole array and grouping each album into a separate array first and making a special array for your album's main photo.

然后就可以通过阵列轻松地重复显示每张专辑和code变得更容易维护。

Then you can easily iterate through the arrays to display each album and the code becomes much more maintainable.

这篇关于Flickr的API phpflickr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆