So we’re finally at the part where I am talking about group pools – now that you know how to get information about groups, you probably want to know how to manage photos that are available in the pool and contribute to the existing set. Well look no further.

Today I will be discussing 5 methods in the groups.pools category.

flickr.groups.pools.add

This is the method you would want to use to add photos to an existing group pool. Note, however, that this method doesn’t let you upload photos – you should already have a photo in your own Flickr collection that will be later on added to an existing group pool.

This method requires three parameters that you’ve probably thought about – the API key, which is tied to your application, the photo ID – this will be the photo that will be added to the pool, and of course the group ID – defining the group that will contain the photo passed.

Assuming that you already have the class skeleton (can be downloaded here), there is the Pools nested class – that’s where we’ll put the implementation for the methods that belong in the Pools category. Inside that class, create a method called Add:

Let’s look at the parameters passed to this method. apiKey has an obvious purpose - it is used to store the API key. The authToken keeps the authentication token that is generated for your application based on the user account that authorized the application to be used with his/her Flickr account. The signature is generated based on the parameter array passed to the method and the unique user identifiers. groupID will be the alphanumeric identifier of the group that will accept the photo and photoID is the photoID itself (note, that you are not sending the photo in binary format but rather as a reference to an existing photo in a Flickr set linked to your account).

There is the HelperDelegate instance set in the parent class that is set to the instance passed to this specific method – it is really helpful when I need to execute an action right after the result is received – saves some time for me to directly work with threading to wait for the asynchronous operation to complete. Then, the WebClient instance will actually be the link between my request and the server response. The URL is built accordingly, considering the passed parameters.

NOTE: The signature for this method is generated outside the method itself. It is tied to a MD5 hashing service that should be launched separately or hosted. In case you were wondering if there is a way to use the service without having to run the service on your own, the answer is – yes, you can. I am hosting the MD5 hashing service at:

http://services.dennisdel.com/md5/MD5HashService.svc

Add a reference to this service and use it just the way you used it in previous samples – it runs on the same core engine.

That is pretty much it for the method – you can test it right away in your main application.

flickr.groups.pools.getContext

So now you have a picture added to the group pool. But you would also like to know what’s the next picture that goes after yours in the pool and what’s the picture that goes before it. getContext is exactly what you need in this case – it returns the IDs of photos that “surround” your own photo in the pool.

The parameter set is the same as for the method above (as there is no additional information needed to find the nearby pictures), so the implementation is exactly like the flickr.groups.pools.add - what you want to do here is just copy and paste the same code block, the only difference being the passed URL – you need to change the method name. So what you need is this:

flickr.groups.pools.getGroups

So now you know how to add photos to a group. But how exactly do you know where you can add photos?

getGroups returns a list of groups (where the user is a member of) that are ready for new pictures to be added to the pool. The implementation of this method shouldn’t be much of a problem since you are already familiar with the basic request structure:

The only difference here is the fact that the number of results can be so high, that it should be separated on various pages, thus the presence of the page and perPage parameters.

flickr.groups.pools.getPhotos

This method might be a bit tricky – mainly because it can be either authenticated or not. If it is not authenticated, then it will get the list of photos in a group if those are accessible for public viewing.

Otherwise, none will be returned and you might want to authorize the call. So let’s look at the parameters used by this method:

Notice that although the method can be unauthenticated, it still requires the API key to identify the calling application. If it is authenticated, then you have to provide the authentication token and sign the call.

The plain method call returns only the basic information and chances are that eventually you will want to get more info about photos to perform specific manipulations with them. In this case, the extras parameter is what you’re looking for – it allows you to specify what additional photo information needs to be attached to the returned result.

The extras parameter can be passed as a string array (the same way I did when I was working on Favorites.GetList) and then each item from the array will be added to the URL.

So the actual implementation based on the requirements I stated above is like this:

Although it might seems like this method is overly complicated – it is not. I do the same thing I did in previous methods, but there are two arrays – tags and extras. Since those aren’t required, I am checking against null to make sure that one is actually passed. In order for those to be ignored, all you have to do is pass null as the value when executing the call.

flickr.groups.pools.remove

Last and the easiest method from this category – it allows you to remove a picture from a group pool. It is absolutely (and by that I mean – 100%) the same as Add, the only difference being the method name passed to the URL. So here it is:

Congratulations! All group operations are now tied to this class. You can download the complete Groups.cs file here. Don't forget that if you plan on using this file, you need to add it to the Core folder inside the solution.