flickr Fotostream for Sets

Creating and modifying plugins.
Post Reply
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

flickr Fotostream for Sets

Post 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!
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: flickr Fotostream for Sets

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: flickr Fotostream for Sets

Post 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...
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: flickr Fotostream for Sets

Post 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) {
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: flickr Fotostream for Sets

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: flickr Fotostream for Sets

Post by peggylon »

Thanks for the compliment *blushing* and speedy help...
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: flickr Fotostream for Sets

Post 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)...
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: flickr Fotostream for Sets

Post 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.
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: flickr Fotostream for Sets

Post by garvinhicking »

Hi!

For sorting, the parameter , "sort" => "date-posted-desc" should be usable, no?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply