public void RemovePhotoFromGroupAsync(string photoId, string groupId) { string timestamp = DateTimeUtils.GetTimestamp(); string nonce = Guid.NewGuid().ToString().Replace("-", null); Dictionary<string, string> paramDict = new Dictionary<string, string>(); paramDict["method"] = "flickr.groups.pools.remove"; 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["group_id"] = groupId; paramDict["photo_id"] = photoId; string signature = OAuthCalculateSignature("POST", "https://api.flickr.com/services/rest/", paramDict, AccessTokenSecret); paramDict["oauth_signature"] = signature; DispatchPostRequest("POST", "https://api.flickr.com/services/rest/", paramDict, (response) => { bool success = true; string errorMessage = ""; try { JObject json = JObject.Parse(response); string status = json["stat"].ToString(); if (status != "ok") { success = false; errorMessage = json["message"].ToString(); } } catch (Exception e) { Debug.WriteLine(e.Message); success = false; } if (!success) { RemovePhotoFromGroupExceptionEventArgs exceptionArgs = new RemovePhotoFromGroupExceptionEventArgs(); exceptionArgs.PhotoId = photoId; exceptionArgs.GroupId = groupId; exceptionArgs.ErrorMessage = errorMessage; RemovePhotoFromGroupException.DispatchEvent(this, exceptionArgs); } else { RemovePhotoFromGroupEventArgs args = new RemovePhotoFromGroupEventArgs(); args.PhotoId = photoId; args.GroupId = groupId; PhotoRemovedFromGroup.DispatchEvent(this, args); } }, (ex) => { RemovePhotoFromGroupExceptionEventArgs exceptionArgs = new RemovePhotoFromGroupExceptionEventArgs(); exceptionArgs.PhotoId = photoId; exceptionArgs.GroupId = groupId; exceptionArgs.ErrorMessage = "Unknown network error"; RemovePhotoFromGroupException.DispatchEvent(this, exceptionArgs); }); }
private void OnPhotoRemovedFromGroup(object sender, RemovePhotoFromGroupEventArgs e) { // Update group throttle info FlickrGroup group = GroupCache[e.GroupId]; Photo photo = PhotoCache[e.PhotoId]; if (group.ThrottleMode != "none") group.ThrottleRemainingCount++; if (group.Photos.Contains(photo)) { group.Photos.Remove(photo); group.PhotoCount--; // Dispatch event RemovePhotoFromGroupCompleteEventArgs evt = new RemovePhotoFromGroupCompleteEventArgs(); evt.PhotoId = photo.ResourceId; evt.GroupId = group.ResourceId; RemovePhotoFromGroupCompleted.DispatchEvent(this, evt); } }