public void CallShare(Share share, Action successCallback, Action failureCallback) { var request = new RestRequest("{service}/{verb}.json", Method.POST); request.AddUrlSegment("service", share.Service); request.AddUrlSegment("verb", "share"); request.AddParameter("access_token", this.AccessToken); request.AddParameter("text", share.Text); request.AddParameter("link", share.Link); if (!string.IsNullOrWhiteSpace(share.Id)) { request.AddParameter("id", share.Id); } this.client.ExecuteAsync(request, (response) => { if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == HttpStatusCode.OK) { System.Diagnostics.Debug.WriteLine(response.Content); successCallback(); } else { System.Diagnostics.Debug.WriteLine("Failure: " + response.ResponseStatus); failureCallback(); } }); }
public void AttemptShare(Share share) { Service service = this.GetService(share.Service, () => { this.AttemptShare(share); }); if (service != null) { if (!service.Authenticated) { share.CallSilentFail(); this.Authenticate(service, () => { }); } else { this.CallShare( share, () => { share.CallSuccess(); }, () => { share.CallFailure(); }); } } }