private async static Task<FlickrResult<string>> GetDataResponseOAuthAsync(Twitter flickr, string method, string baseUrl, Dictionary<string, string> parameters) { if (parameters.ContainsKey("api_key")) parameters.Remove("api_key"); if (parameters.ContainsKey("api_sig")) parameters.Remove("api_sig"); if (!String.IsNullOrEmpty(flickr.OAuthAccessToken) && !parameters.ContainsKey("oauth_token")) { parameters.Add("oauth_token", flickr.OAuthAccessToken); } if (!String.IsNullOrEmpty(flickr.OAuthAccessTokenSecret) && !parameters.ContainsKey("oauth_signature")) { string sig = flickr.OAuthCalculateSignatureForCalls(method, baseUrl, parameters, flickr.OAuthAccessTokenSecret); parameters.Add("oauth_signature", sig); } string data = OAuthCalculatePostData(parameters); string authHeader = OAuthCalculateAuthHeader(parameters); baseUrl = baseUrl.Split("?".ToCharArray())[0]; if (method == "GET") return await DownloadDataAsync(method, baseUrl, data, GetContentType, authHeader); else return await DownloadDataAsync(method, baseUrl, data, PostContentType, authHeader); }
public DefaultViewModel() { apiKey = AppService.AppSetting.FlickrKey; apiSecret = AppService.AppSetting.FlickrSecret; _flickr = new FlickrNet.Flickr(apiKey, apiSecret); _twitter = new FlickrNet.Twitter(apiKey2, apiSecret2); }
/// <summary> /// Gets a data response for the given base url and parameters, /// either using OAuth or not depending on which parameters were passed in. /// </summary> /// <param name="flickr">The current instance of the <see cref="Flickr"/> class.</param> /// <param name="baseUrl">The base url to be called.</param> /// <param name="parameters">A dictionary of parameters.</param> /// <param name="callback"></param> /// <returns></returns> public async static Task<FlickrResult<string>> GetDataResponseAsync(Twitter flickr, string method, string baseUrl, Dictionary<string, string> parameters) { bool oAuth = parameters.ContainsKey("oauth_consumer_key"); if (oAuth) return await GetDataResponseOAuthAsync(flickr, method, baseUrl, parameters); else return await GetDataResponseNormalAsync(flickr, baseUrl, parameters); }
/// <summary> /// Gets a data response for the given base url and parameters, /// either using OAuth or not depending on which parameters were passed in. /// </summary> /// <param name="flickr">The current instance of the <see cref="Flickr"/> class.</param> /// <param name="baseUrl">The base url to be called.</param> /// <param name="parameters">A dictionary of parameters.</param> /// <param name="callback"></param> /// <returns></returns> public async static Task <FlickrResult <string> > GetDataResponseAsync(Twitter flickr, string method, string baseUrl, Dictionary <string, string> parameters) { bool oAuth = parameters.ContainsKey("oauth_consumer_key"); if (oAuth) { return(await GetDataResponseOAuthAsync(flickr, method, baseUrl, parameters)); } else { return(await GetDataResponseNormalAsync(flickr, baseUrl, parameters)); } }
private async static Task<FlickrResult<string>> GetDataResponseNormalAsync(Twitter flickr, string baseUrl, Dictionary<string, string> parameters) { string method = flickr.CurrentService == SupportedService.Zooomr ? "GET" : "POST"; string data = String.Empty; foreach (var k in parameters) { data += k.Key + "=" + Uri.EscapeDataString(k.Value) + "&"; } if (method == "GET" && data.Length > 2000) method = "POST"; if (method == "GET") return await DownloadDataAsync(method, baseUrl + "?" + data, null, null, null); else return await DownloadDataAsync(method, baseUrl, data, PostContentType, null); }
private async static Task <FlickrResult <string> > GetDataResponseOAuthAsync(Twitter flickr, string method, string baseUrl, Dictionary <string, string> parameters) { if (parameters.ContainsKey("api_key")) { parameters.Remove("api_key"); } if (parameters.ContainsKey("api_sig")) { parameters.Remove("api_sig"); } if (!String.IsNullOrEmpty(flickr.OAuthAccessToken) && !parameters.ContainsKey("oauth_token")) { parameters.Add("oauth_token", flickr.OAuthAccessToken); } if (!String.IsNullOrEmpty(flickr.OAuthAccessTokenSecret) && !parameters.ContainsKey("oauth_signature")) { string sig = flickr.OAuthCalculateSignatureForCalls(method, baseUrl, parameters, flickr.OAuthAccessTokenSecret); parameters.Add("oauth_signature", sig); } string data = OAuthCalculatePostData(parameters); string authHeader = OAuthCalculateAuthHeader(parameters); baseUrl = baseUrl.Split("?".ToCharArray())[0]; if (method == "GET") { return(await DownloadDataAsync(method, baseUrl, data, GetContentType, authHeader)); } else { return(await DownloadDataAsync(method, baseUrl, data, PostContentType, authHeader)); } }
private async static Task <FlickrResult <string> > GetDataResponseNormalAsync(Twitter flickr, string baseUrl, Dictionary <string, string> parameters) { string method = flickr.CurrentService == SupportedService.Zooomr ? "GET" : "POST"; string data = String.Empty; foreach (var k in parameters) { data += k.Key + "=" + Uri.EscapeDataString(k.Value) + "&"; } if (method == "GET" && data.Length > 2000) { method = "POST"; } if (method == "GET") { return(await DownloadDataAsync(method, baseUrl + "?" + data, null, null, null)); } else { return(await DownloadDataAsync(method, baseUrl, data, PostContentType, null)); } }