Over a million developers have joined DZone.

Flickr API for Windows Phone 7 – Part 11- Group Membership

· Mobile Zone

In my previous article I’ve shown how to query Flickr to obtain lists of groups, that might be useful when looking for content and/or looking for groups where you can publish your content. Here, I am going to show how to retrieve the list of members that relate to a specific group.

A list of people who are members of a specific group is retrieved via flickr.groups.members.getList. This method requires authentication, but provides quite a few options when it comes to the types of members you want to retrieve.

First of all, there are three types of members: regular members, moderators and admins. These user categories are identified by a numeric value – 2 for regular members, 3 for moderators and 4 for admins. The ID equal to 1 is assigned to a narwhal user group is not returned by this API call. What this member group represents is unknown.

You can query the member list without specifying the user group and you will get everyone who is a member of that group. Remember that a group ID will be required here, since membership is connected to a group anyway.

You should already have the class structure outlined in my previous article. Inside the Members class (which is nested), create a method called GetList.

public static void GetList(string apiKey,string authToken, string signature, string groupID, HelperDelegate helperDelegate,
                string page="", string perPage ="")


This is the very basic method implementation and it is in no way the complete GetList. So what’s missing here? First of all, there should be the possibility to set what user categories should be selected. Now the interesting thing is the fact that this won’t necessarily be a single integer. For example, someone would want to query both admins and moderators, but not regular users. This is passed to the membertypes parameter via a comma, in case there is more than one parameter required.

So for the example outlined above, my parameter with its values will be structured like this:


So how exactly can this be passed to the method? There are two basic ways – you can either request an array of numeric values with the IDs to be included as parameter values or use Boolean values that will represent each user type, defining whether those should be selected or not.

The main drawback of the first method is that the user can provide incorrect values and that will result in a failed request. The second one involves too many checking layers, so it will create some code sections that won’t look pretty at all.

Another solution is implementing an enum that will ensure that there is no way the user will pass incorrect values. But by default, enums don’t support string enumerations, so I am using a static class instead:

public static class SelectedTypes
    public const string All = "2,3,4";
    public const string Regular = "2";
    public const string Mod = "3";
    public const string Admin = "4";
    public const string RegularAndMod = "2,3";
    public const string RegularAndAdmin = "2,4";
    public const string ModAndAdmin = "3,4";

Basically, it is the same first method under a different cover, but it minimzes the chance of an incorrect value. There is a workaround that will let you use string enumerations, but that will involve reflection and attribute usage, so for now a static class will do.

I am now required to add another mandatory parameter to the method: string types. The method will automatically receive the correct string values depending on the selected type, if you use the static class reference. Of course, you could enter the values by yourself, but you will have to check them for correctness by yourself.

Let’s look at the core of this method:

helperDelegateInstance = helperDelegate;

WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Core.Groups.client_DownloadStringCompleted);
string URL = string.Format("http://www.flickr.com/services/rest/?method=flickr.groups.members.getList&api_key={0}&format=json&auth_token={1}&api_sig={2}&membertypes={3}&group_id={4}",
                        apiKey, authToken, signature,types,groupID);

if (page != "")
    URL += "&page=" + page;
if (perPage != "")
    URL += "&per_page=" + perPage;

client.DownloadStringAsync(new Uri(URL));

Notice that I am referencing the event handler that is placed outside the nested class, therefore I have to use the fully qualified name.

Execute this method like this:

Core.Authentication.GetSignature(param, "SECRET", () =>
    Core.Groups.Members.GetList(apiKey, "TOKEN", Core.Authentication.Signature,"GROUPID",Core.Groups.Members.SelectedTypes.All,
    () =>

You can download the updated Groups.cs here.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}