UrlEncode() private static method

private static UrlEncode ( string>.IEnumerable parameters ) : string
parameters string>.IEnumerable
return string
Exemplo n.º 1
0
        // Token: 0x06002F40 RID: 12096 RVA: 0x000E525C File Offset: 0x000E365C
        private static string GetFinalOAuthHeader(string HTTPRequestType, string URL, Dictionary <string, string> parameters)
        {
            string value = API.GenerateSignature(HTTPRequestType, URL, parameters);

            parameters.Add("oauth_signature", value);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("OAuth realm=\"{0}\"", "Twitter API");
            IOrderedEnumerable <KeyValuePair <string, string> > orderedEnumerable = from p in parameters
                                                                                    where API.OAuthParametersToIncludeInHeader.Contains(p.Key)
                                                                                    orderby p.Key, API.UrlEncode(p.Value)
            select p;

            foreach (KeyValuePair <string, string> keyValuePair in orderedEnumerable)
            {
                stringBuilder.AppendFormat(",{0}=\"{1}\"", API.UrlEncode(keyValuePair.Key), API.UrlEncode(keyValuePair.Value));
            }
            stringBuilder.AppendFormat(",oauth_signature=\"{0}\"", API.UrlEncode(parameters["oauth_signature"]));
            return(stringBuilder.ToString());
        }
Exemplo n.º 2
0
        // Token: 0x06002F46 RID: 12102 RVA: 0x000E5654 File Offset: 0x000E3A54
        private static string UrlEncode(IEnumerable <KeyValuePair <string, string> > parameters)
        {
            StringBuilder stringBuilder = new StringBuilder();
            IOrderedEnumerable <KeyValuePair <string, string> > orderedEnumerable = from p in parameters
                                                                                    orderby p.Key, p.Value
            select p;

            foreach (KeyValuePair <string, string> keyValuePair in orderedEnumerable)
            {
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append("&");
                }
                stringBuilder.Append(string.Format(CultureInfo.InvariantCulture, "{0}={1}", new object[]
                {
                    API.UrlEncode(keyValuePair.Key),
                    API.UrlEncode(keyValuePair.Value)
                }));
            }
            return(API.UrlEncode(stringBuilder.ToString()));
        }
Exemplo n.º 3
0
        // Token: 0x06002F41 RID: 12097 RVA: 0x000E5388 File Offset: 0x000E3788
        private static string GenerateSignature(string httpMethod, string url, Dictionary <string, string> parameters)
        {
            IEnumerable <KeyValuePair <string, string> > parameters2 = from p in parameters
                                                                       where !API.SecretParameters.Contains(p.Key)
                                                                       select p;
            string s = string.Format(CultureInfo.InvariantCulture, "{0}&{1}&{2}", new object[]
            {
                httpMethod,
                API.UrlEncode(API.NormalizeUrl(new Uri(url))),
                API.UrlEncode(parameters2)
            });
            string s2 = string.Format(CultureInfo.InvariantCulture, "{0}&{1}", new object[]
            {
                API.UrlEncode(parameters["oauth_consumer_secret"]),
                (!parameters.ContainsKey("oauth_token_secret")) ? string.Empty : API.UrlEncode(parameters["oauth_token_secret"])
            });
            HMACSHA1 hmacsha = new HMACSHA1(Encoding.ASCII.GetBytes(s2));

            byte[] inArray = hmacsha.ComputeHash(Encoding.ASCII.GetBytes(s));
            return(Convert.ToBase64String(inArray));
        }