コード例 #1
0
ファイル: TwitterResponderAsync.cs プロジェクト: liquidboy/X
        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);

        }
コード例 #2
0
        public DefaultViewModel()
        {
            apiKey    = AppService.AppSetting.FlickrKey;
            apiSecret = AppService.AppSetting.FlickrSecret;

            _flickr  = new FlickrNet.Flickr(apiKey, apiSecret);
            _twitter = new FlickrNet.Twitter(apiKey2, apiSecret2);
        }
コード例 #3
0
ファイル: TwitterResponderAsync.cs プロジェクト: liquidboy/X
        /// <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);
        }
コード例 #4
0
        /// <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));
            }
        }
コード例 #5
0
ファイル: TwitterResponderAsync.cs プロジェクト: liquidboy/X
        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);
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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));
            }
        }