Page 1 of 1
flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 11:18 am
by peggylon
Hello,
I have been usinf flickr Fotostream (serendipity_plugin_flickr) for inclusion of my Flickr pictures.
Lately I sorted pictures into so called sets. I'd like to select only one of them for inclusion in Serendipity.
Is there a chance to update the flickr plugin in a way, that users can limit their foto stream to one or a variety of sets?
If that's not possible I'd like to get hints off how to modify seredipity_plugin_flickr.php in order to get the desired result. I know what the calling url would have to look like, but have no clue how to achieve that via Flickr API.
Thank you!
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 12:18 pm
by garvinhicking
Hi!
Yes, currently the flickr plugin is quite basic. But it uses the underlying phpFlickr API that is quite powerful.
In the serendipity_plugin_flickr.php file you can see this at around line 204:
Code: Select all
$photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $num, "sort" => "date-posted-desc", "extras" => "date_taken"));
That's the actual call to fetch photos. I think you could easily change those attributes to add a album ID or so?
The API documentation points to
http://www.flickr.com/services/api/flic ... earch.html - I didn't spot a "album id" in first place, but something like that must exist...
HTH,
Garvin
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 1:24 pm
by peggylon
Thx Garvin!
Unfortunately there is no such argument as set-id for photo search. One way to achieve some sort of filtering would be to use a certain tag for all pictures in the album I want to include. Seems that photos_search() allows filtering by tags.
I also tried the following:
Code: Select all
$photos = $f->photosets_getPhotos (array('photoset_id' => '72157623591581540', 'extras' => 'date_taken', 'per_page' => $num, 'media' => 'photos'));
instead of:
Code: Select all
$photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $num, "sort" => "date-posted-desc", "extras" => "date_taken"));
But I get an output saying, that there are no pictures available...
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 2:17 pm
by peggylon
I figured it out now...
A couple lines have to be edited:
Code: Select all
$photos = $f->photosets_getPhotos(array("photoset_id" => "72157623591581540", "extras" => "date_taken", "per_page" => $num, "media" => 'photos'));
// $photos = $f->photos_search(...);
foreach($photos['photoset']['photo'] as $photo) {
// foreach($photos['photo'] as $photo) {
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 2:37 pm
by garvinhicking
Hi!
Ah, great progress! I also had a look at your site - very well done and nicely customized!
I wish I could be more of help here, but I haven't really worked with the flickr API in a long time...
Regards,
Garvin
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 3:01 pm
by peggylon
Thanks for the compliment *blushing* and speedy help...
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 4:20 pm
by peggylon
That's weird!
Briefly I got the desired pictures displayed for some reason...
But the code I postet above is NOT working. (wrong function parameters)
The way to select pictures from a set is as follows:
Code: Select all
$photos = $f->photosets_getPhotos("set_id", NULL , NULL, $num, NULL, "photos");
// instead of
// $photos = $f->photos_search(...);
if($photos['photoset'][total] > 0 && $f) {
// instead of
// if($photos[total] > 0 && $f) {
foreach($photos['photoset']['photo'] as $photo) {
// instead of
// foreach($photos['photo'] as $photo) {
// if ($photo['ispublic'] !== 1) continue;
// the 'ispublic' option is not in the array, therefore this line needs to be commented out.
Unfortunately there is no sorting option, which means one would either have to read all pictures in the set (up to 500) and then reverse the array $photos['photoset']['photo'] in order to get the latest ones displayed. Or when using parameter per_page than you always get that number of pictures starting from picture one in your set.
Very frustrating. I guess I have worked in vain and have to resort to plan B (using tags for filtering)...
Re: flickr Fotostream for Sets
Posted: Fri Nov 05, 2010 6:25 pm
by peggylon
Despite this turned out to be kind of a monologue, it might be helpful for those who intend to display selected sets of their flickr photos in s9y...
Happily, the missing sorting attribute is no problem. Sets can be sorted in Flickr directly. I sorted mine newest first.
If you then follow the steps pointed out in the previos part, you should be able to display pictures from the set(s) you want displayed, only.
Re: flickr Fotostream for Sets
Posted: Sat Nov 06, 2010 1:26 pm
by garvinhicking
Hi!
For sorting, the parameter , "sort" => "date-posted-desc" should be usable, no?
Regards,
Garvin