FlickrNet.FlickrResponder.GetDataResponseAsync C# (CSharp) Method

GetDataResponseAsync() public static method

Gets a data response for the given base url and parameters, either using OAuth or not depending on which parameters were passed in.
public static GetDataResponseAsync ( Flickr flickr, string hashCall, string baseUrl, string>.Dictionary parameters ) : Task>
flickr Flickr The current instance of the class.
hashCall string
baseUrl string The base url to be called.
parameters string>.Dictionary A dictionary of parameters.
return Task>
        public static async Task<FlickrResult<string>> GetDataResponseAsync(Flickr flickr, string hashCall, string baseUrl, Dictionary<string, string> parameters)
        {
            bool oAuth = parameters.ContainsKey("oauth_consumer_key");

            if (oAuth)
                return await GetDataResponseOAuthAsync(flickr, hashCall, baseUrl, parameters);
            else
                return await GetDataResponseNormalAsync(flickr, hashCall, baseUrl, parameters);
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Get an <see cref="OAuthRequestToken"/> for the given callback URL.
        /// </summary>
        /// <remarks>Specify 'oob' as the callback url for no callback to be performed.</remarks>
        /// <param name="callbackUrl">The callback Uri, or 'oob' if no callback is to be performed.</param>
        /// <param name="callback"></param>
        async public Task <bool> OAuthGetRequestTokenAsync(string callbackUrl, Action <FlickrResult <OAuthRequestToken> > callback)
        {
            string url = "http://www.flickr.com/services/oauth/request_token";

            Dictionary <string, string> parameters = OAuthGetBasicParameters();

            parameters.Add("oauth_callback", callbackUrl);

            string sig = OAuthCalculateSignature("POST", url, parameters, null);

            parameters.Add("oauth_signature", sig);

            FlickrResponder.GetDataResponseAsync(this, url, parameters, (r) =>
            {
                FlickrResult <OAuthRequestToken> result = new FlickrResult <OAuthRequestToken>();
                if (r.Error != null)
                {
                    if (r.Error is System.Net.WebException)
                    {
                        OAuthException ex = new OAuthException(r.Error);
                        result.Error      = ex;
                    }
                    else
                    {
                        result.Error = r.Error;
                    }
                    callback(result);
                    return;
                }
                result.Result = FlickrNet.OAuthRequestToken.ParseResponse(r.Result);
                callback(result);
            });

            return(true);
        }
All Usage Examples Of FlickrNet.FlickrResponder::GetDataResponseAsync