// Contact list returned
        private void OnContactListReturned(object sender, GetContactListEventArgs e)
        {
            JObject rawJson = JObject.Parse(e.Response);
            JObject rootJson = (JObject)rawJson["contacts"];
            ContactCount = int.Parse(rootJson["total"].ToString());
            int page = int.Parse(rootJson["page"].ToString());
            int numPages = int.Parse(rootJson["pages"].ToString());
            int perPage = int.Parse(rootJson["perpage"].ToString());

            List<User> newUsers = new List<User>();
            if (ContactCount > 0)
            {
                foreach (var entry in rootJson["contact"])
                {
                    JObject json = (JObject)entry;
                    User contact = UserFactory.ContactWithJObject(json);

                    if (!ContactList.Contains(contact))
                    {
                        ContactList.Add(contact);
                        newUsers.Add(contact);
                    }
                }
            }

            // Dispatch event
            ContactListUpdatedEventArgs evt = new ContactListUpdatedEventArgs();
            evt.Page = page;
            evt.PageCount = numPages;
            evt.PerPage = perPage;
            evt.NewUsers = newUsers;
            ContactListUpdated.DispatchEvent(this, evt);
        }
        public async void GetContactListAsync(int page, int perPage, Dictionary<string, string> parameters = null)
        {
            if (isLoadingContactList)
                return;

            isLoadingContactList = true;

            string timestamp = DateTimeUtils.GetTimestamp();
            string nonce = Guid.NewGuid().ToString().Replace("-", null);

            Dictionary<string, string> paramDict = new Dictionary<string, string>();
            paramDict["method"] = "flickr.contacts.getList";
            paramDict["format"] = "json";
            paramDict["nojsoncallback"] = "1";
            paramDict["oauth_consumer_key"] = consumerKey;
            paramDict["oauth_nonce"] = nonce;
            paramDict["oauth_signature_method"] = "HMAC-SHA1";
            paramDict["oauth_timestamp"] = timestamp;
            paramDict["oauth_token"] = AccessToken;
            paramDict["oauth_version"] = "1.0";
            paramDict["page"] = page.ToString();
            paramDict["per_page"] = perPage.ToString();

            if (parameters != null)
            {
                foreach (var entry in parameters)
                {
                    paramDict[entry.Key] = entry.Value;
                }
            }

            string paramString = GenerateParamString(paramDict);
            string signature = GenerateSignature("GET", AccessTokenSecret, "https://api.flickr.com/services/rest", paramString);
            string requestUrl = "https://api.flickr.com/services/rest?" + paramString + "&oauth_signature=" + signature;
            HttpWebResponse response = await DispatchRequest("GET", requestUrl, null).ConfigureAwait(false);
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                isLoadingContactList = false;

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    var exceptionEvt = new GetContactListExceptionEventArgs();
                    exceptionEvt.Page = page;
                    exceptionEvt.PerPage = perPage;
                    GetContactListException.DispatchEvent(this, exceptionEvt);

                    HandleHTTPException(response);
                    return;
                }

                string jsonString = await reader.ReadToEndAsync().ConfigureAwait(false);
                if (!TryHandleResponseException(jsonString, 
                    () => { 
                        GetContactListAsync(page, perPage, parameters); 
                    }, 
                    () => {
                        var exceptionEvt = new GetContactListExceptionEventArgs();
                        exceptionEvt.Page = page;
                        exceptionEvt.PerPage = perPage;
                        GetContactListException.DispatchEvent(this, exceptionEvt);
                }))
                    return;

                GetContactListEventArgs args = new GetContactListEventArgs();
                args.Page = page;
                args.PerPage = perPage;
                args.Response = jsonString;
                ContactListReturned.DispatchEvent(this, args);
            }
        }