当前位置: 首页>>代码示例>>C#>>正文


C# SortedDictionary.ToWebString方法代码示例

本文整理汇总了C#中SortedDictionary.ToWebString方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.ToWebString方法的具体用法?C# SortedDictionary.ToWebString怎么用?C# SortedDictionary.ToWebString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortedDictionary的用法示例。


在下文中一共展示了SortedDictionary.ToWebString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TwitterLinkBuilder

        public string TwitterLinkBuilder(string q)
        {
            string ret = string.Empty;
            JArray output = new JArray();
            SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
            try
            {
                var oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=" + q.Trim() + "&result_type=recent";
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAOZyVwAAAAAAgI0VcykgJ600le2YdR4uhKgjaMs%3D0MYOt4LpwCTAIi46HYWa85ZcJ81qi0D9sh8avr1Zwf7BDzgdHT");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());
                }
                List<string> _lst = new List<string>();
                foreach (var item in output)
                {
                    try
                    {
                        string _urls = item["entities"]["urls"][0]["expanded_url"].ToString();
                        if (!string.IsNullOrEmpty(_urls))
                            _lst.Add(_urls);
                    }
                    catch { }
                }

                ret = new JavaScriptSerializer().Serialize(_lst);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                ret = "";
            }

            return ret; 
        }
开发者ID:prog-moh,项目名称:socioboard-core,代码行数:49,代码来源:LinkBuilder.asmx.cs

示例2: GetResponse

        private string GetResponse(string resourceUrl, Method method, SortedDictionary requestParameters)
        {
            ServicePointManager.Expect100Continue = false;
            WebRequest request = null;
            string resultString = string.Empty;

            if (method == Method.POST)
            {
                var postBody = requestParameters.ToWebString();
                request = (HttpWebRequest)WebRequest.Create(resourceUrl);
                request.Method = method.ToString();
                request.ContentType = "application/x-www-form-urlencoded";

                using (var stream = request.GetRequestStream())
                {
                    byte[] content = Encoding.ASCII.GetBytes(postBody);
                    stream.Write(content, 0, content.Length);
                }
            }
            else if (method == Method.GET)
            {
                request = (HttpWebRequest)WebRequest.Create(resourceUrl + "?" + requestParameters.ToWebString());
                request.Method = method.ToString();
            }
            else
            {
                //other verbs can be addressed here...
            }

            if (request != null)
            {
                var authHeader = CreateHeader(resourceUrl, method, requestParameters);
                request.Headers.Add("Authorization", authHeader);
                var response = request.GetResponse();

                using (var sd = new StreamReader(response.GetResponseStream()))
                {
                    resultString = sd.ReadToEnd(); response.Close();
                }
            }
            return resultString;
        }
开发者ID:suthaharan,项目名称:twitter-trace,代码行数:42,代码来源:Twitter.cs

示例3: CreateOauthSignature

        private string CreateOauthSignature(string resourceUrl, Method method, string oauthNonce, string oauthTimestamp, SortedDictionary requestParameters)
        {
            //firstly we need to add the standard oauth parameters to the sorted list
            requestParameters.Add("oauth_consumer_key", ConsumerKey);
            requestParameters.Add("oauth_nonce", oauthNonce);
            requestParameters.Add("oauth_signature_method", OauthSignatureMethod);
            requestParameters.Add("oauth_timestamp", oauthTimestamp);
            requestParameters.Add("oauth_token", AccessToken);
            requestParameters.Add("oauth_version", OauthVersion);
            var sigBaseString = requestParameters.ToWebString();
            var signatureBaseString = string.Concat(method.ToString(), "&", Uri.EscapeDataString(resourceUrl), "&", Uri.EscapeDataString(sigBaseString.ToString()));
            //Using this base string, we then encrypt the data using a composite of the
            //secret keys and the HMAC-SHA1 algorithm.

            var compositeKey = string.Concat(Uri.EscapeDataString(ConsumerKeySecret), "&", Uri.EscapeDataString(AccessTokenSecret));
            string oauthSignature;
            using (var hasher = new HMACSHA1(Encoding.ASCII.GetBytes(compositeKey)))
            {
                oauthSignature = Convert.ToBase64String(hasher.ComputeHash(Encoding.ASCII.GetBytes(signatureBaseString)));
            }
            return oauthSignature;
        }
开发者ID:suthaharan,项目名称:twitter-trace,代码行数:22,代码来源:Twitter.cs

示例4: CreateOauthSignature

        public string CreateOauthSignature(string resourceUrl, Method method, string oauthNonce, string oauthTimestamp,
                                            SortedDictionary<string, string> requestParameters)
        {
            //firstly we need to add the standard oauth parameters to the sorted list

            string oauthSignature=string.Empty;

            try
            {
                try
                {
                    requestParameters.Add("oauth_consumer_key", ConsumerKey);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    requestParameters.Add("oauth_nonce", oauthNonce);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    requestParameters.Add("oauth_signature_method", OauthSignatureMethod);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    requestParameters.Add("oauth_timestamp", oauthTimestamp);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!string.IsNullOrEmpty(AccessToken))
                {
                    try
                    {
                        requestParameters.Add("oauth_token", AccessToken);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                try
                {
                    requestParameters.Add("oauth_version", OauthVersion);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    if (!string.IsNullOrEmpty(OAuthVerifer))

                        try
                        {
                            requestParameters.Add("oauth_verifier", OAuthVerifer);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                }

                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);

                }


                var sigBaseString = requestParameters.ToWebString();

                var signatureBaseString = string.Concat(method.ToString(), "&", Uri.EscapeDataString(resourceUrl), "&",
                                                        Uri.EscapeDataString(sigBaseString.ToString()));


                //Using this base string, we then encrypt the data using a composite of the 
                //secret keys and the HMAC-SHA1 algorithm.
                var compositeKey = string.Concat(Uri.EscapeDataString(ConsumerKeySecret), "&",
                                                 Uri.EscapeDataString(AccessTokenSecret));



                using (var hasher = new HMACSHA1(Encoding.ASCII.GetBytes(compositeKey)))
                {
                    oauthSignature = Convert.ToBase64String(
                        hasher.ComputeHash(Encoding.ASCII.GetBytes(signatureBaseString)));
//.........这里部分代码省略.........
开发者ID:JBNavadiya,项目名称:socioboard,代码行数:101,代码来源:oAuthTwitter.cs

示例5: oAuthWebRequest

        /// <summary>
        /// Submit a web request using oAuth.
        /// </summary>
        /// <param name="method">GET or POST</param>
        /// <param name="url">The full url, including the querystring.</param>
        /// <param name="postData">Data to post (querystring format)</param>
        /// <returns>The web server response.</returns>
        public string oAuthWebRequest(Method method, string resourceUrl, SortedDictionary<string, string> requestParameters)
        {
            

            string resultString = string.Empty;

            try
            {
                ServicePointManager.Expect100Continue = false;
                HttpWebRequest request = null;


                if (method == Method.POST)
                {
                    var postBody = requestParameters.ToWebString();

                    request = (HttpWebRequest)WebRequest.Create(resourceUrl);
                    request.Method = method.ToString();
                    //if (resourceUrl == Globals.StatusUpdateUrl)
                    //{
                    //    request.ContentType = "multipart/form-data; type=\"image/jpeg\"; start=\"<media>\";boundary=\"--0246824681357ACXZabcxyz\"";

                    //}
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.ProtocolVersion = HttpVersion.Version11;
                    using (var stream = request.GetRequestStream())
                    {
                        byte[] content = Encoding.ASCII.GetBytes(postBody);
                        stream.Write(content, 0, content.Length);
                    }
                }
                else if (method == Method.GET)
                {
                    request = (HttpWebRequest)WebRequest.Create(resourceUrl + "?"
                    + requestParameters.ToWebString());
                    request.Method = method.ToString();

                }
                else
                {
                    //other verbs can be addressed here...
                }

                if (request != null)
                {

                    var authHeader = CreateHeader(resourceUrl, method, requestParameters);
                    request.Headers.Add("Authorization", authHeader);
                    var response = request.GetResponse();

                    using (var sd = new StreamReader(response.GetResponseStream()))
                    {
                        resultString = sd.ReadToEnd();
                        response.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }

            return resultString;
        }
开发者ID:JBNavadiya,项目名称:socioboard,代码行数:71,代码来源:oAuthTwitter.cs

示例6: GetResponse

        private string GetResponse(string resourceUrl, string methodName, SortedDictionary<string, string> requestParameters)
        {
            ServicePointManager.Expect100Continue = false;
            WebRequest request = null;
            string resultString = string.Empty;

            request = (HttpWebRequest)WebRequest.Create(resourceUrl + "?" + requestParameters.ToWebString());
            request.Method = methodName;
            request.ContentType = "application/x-www-form-urlencoded";

            if (request != null)
            {
                var authHeader = CreateHeader(resourceUrl, methodName, requestParameters);
                request.Headers.Add("Authorization", authHeader);

                var response = (HttpWebResponse)request.GetResponse();
                using (var sd = new StreamReader(response.GetResponseStream()))
                {
                    resultString = sd.ReadToEnd();
                    response.Close();
                }
            }
            return resultString;
        }
开发者ID:AzureDay,项目名称:2016-SocialCounter,代码行数:24,代码来源:TwitterHelper.cs

示例7: GetTwitterWebMentions

        public void GetTwitterWebMentions(string HostName)
        {
            try
            {
                HostName = HostName.Replace("www.", "");
                JArray output = new JArray();
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                try
                {
                    var oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=" + HostName.Trim() + "&result_type=recent&count=30";
                    var headerFormat = "Bearer {0}";
                    var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAOZyVwAAAAAAgI0VcykgJ600le2YdR4uhKgjaMs%3D0MYOt4LpwCTAIi46HYWa85ZcJ81qi0D9sh8avr1Zwf7BDzgdHT");

                    var postBody = requestParameters.ToWebString();
                    ServicePointManager.Expect100Continue = false;

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                           + requestParameters.ToWebString());

                    request.Headers.Add("Authorization", authHeader);
                    request.Method = "GET";
                    request.Headers.Add("Accept-Encoding", "gzip");
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                    using (var reader = new StreamReader(responseStream))
                    {
                        var objText = reader.ReadToEnd();
                        output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());
                    }
                }
                catch (Exception ex)
                {
                }
                Domain.Socioboard.MongoDomain.TwitterUrlMentions _TwitterUrlMentions;
                try
                {
                    foreach (var chile in output)
                    {
                        try
                        {
                            _TwitterUrlMentions = new Domain.Socioboard.MongoDomain.TwitterUrlMentions();
                            _TwitterUrlMentions.Id = ObjectId.GenerateNewId();
                            _TwitterUrlMentions.Feed = chile["text"].ToString();
                            _TwitterUrlMentions.Feeddate = Utility.ParseTwitterTime(chile["created_at"].ToString()).ToUnixTimestamp();
                            _TwitterUrlMentions.FeedId = chile["id_str"].ToString();
                            _TwitterUrlMentions.FromId = chile["user"]["id_str"].ToString();
                            _TwitterUrlMentions.FromImageUrl = chile["user"]["profile_image_url"].ToString();
                            _TwitterUrlMentions.FromName = chile["user"]["screen_name"].ToString();
                            _TwitterUrlMentions.HostName = HostName;

                            var ret = TwtsearchRepo.Find<Domain.Socioboard.MongoDomain.TwitterUrlMentions>(t => t.FeedId.Equals(_TwitterUrlMentions.FeedId) && t.HostName.Equals(_TwitterUrlMentions.HostName));
                            var task = Task.Run(async () =>
                            {
                                return await ret;
                            });
                            int count = task.Result.Count;

                            if (count < 1)
                            {
                                TwtsearchRepo.Add(_TwitterUrlMentions);
                            }
                        }
                        catch { }
                    }
                }
                catch { }
            }
            catch { }
        }
开发者ID:socioboard,项目名称:socioboard-core,代码行数:69,代码来源:GoogleAnalytics.asmx.cs

示例8: TwitterBoardUserPreviousTimeLine

        public string TwitterBoardUserPreviousTimeLine(string ScreenName, string LastTweetId)
        {
            JArray output = new JArray();
            try
            {
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                //requestParameters.Add("user_id", UserId);
                requestParameters.Add("screen_name", ScreenName);
                if (!string.IsNullOrEmpty(LastTweetId))
                {
                    requestParameters.Add("max_id", LastTweetId);

                }
                requestParameters.Add("count", "95");

                //Token URL
                var oauth_url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAEB7gwAAAAAA2Jk7qBC%2BWVA5tHGEoNn2Z9bayGU%3DNn0MsaxfRaMIsZ0b5UeHymBwl61Sc9TjBR0FokROqonw5a1t3F");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(objText);

                }
            }
            catch (Exception ee) { }

            return output.ToString();
        }
开发者ID:socioboard,项目名称:socioboard-core,代码行数:44,代码来源:Companypage.asmx.cs

示例9: TwitterBoardUserTimeLine

        public string TwitterBoardUserTimeLine(string ScreenName, string LastTweetId)
        {
            JArray output = new JArray();
            try
            {
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                //requestParameters.Add("user_id", UserId);
                requestParameters.Add("screen_name", ScreenName);
                if (!string.IsNullOrEmpty(LastTweetId))
                {
                    requestParameters.Add("since_id", LastTweetId);
                }
                //Token URL
                var oauth_url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAKFPggAAAAAArwWHS2FBX%2FkwQQa40yoy3yLxP0Y%3DQW1M1gGoVK1b4WLdQ8gg0lMB7m4gPnAzDTNijQENJrKVocyBfX");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(objText);

                }
            }
            catch (Exception ee) { }

            return output.ToString();
        }
开发者ID:sumitglobussoft,项目名称:myfashionmarketer,代码行数:41,代码来源:Companypage.asmx.cs

示例10: TwitterTweetSearchWithGeoLocation

        public string TwitterTweetSearchWithGeoLocation(string q, string geoCode)
        {
            if (q.Contains("#"))
            {
                q = Uri.EscapeUriString(q);
            }
            try
            {
                string url = string.Empty;
                if (!string.IsNullOrEmpty(geoCode))
                {
                    url = q.Trim() + "&geocode=" + geoCode + "&count=20&result_type=recent";
                }
                else
                {
                    url = q.Trim() + "&count=20&result_type=recent";
                }
                string ret = string.Empty;
                JArray output = new JArray();
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();

                var oauth_url = "https://api.twitter.com/1.1/search/tweets.json?q=" + url;
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAOZyVwAAAAAAgI0VcykgJ600le2YdR4uhKgjaMs%3D0MYOt4LpwCTAIi46HYWa85ZcJ81qi0D9sh8avr1Zwf7BDzgdHT");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());
                }
                Domain.Socioboard.Helper.Discovery _Discovery;
                List<Domain.Socioboard.Helper.Discovery> lstDiscovery = new List<Domain.Socioboard.Helper.Discovery>();
                try
                {
                    foreach (var item in output)
                    {
                        try
                        {
                            _Discovery = new Domain.Socioboard.Helper.Discovery();

                            _Discovery.text = item["text"].ToString();
                            _Discovery.created_at = Utility.ParseTwitterTime(item["created_at"].ToString());
                            _Discovery.tweet_id = item["id_str"].ToString();
                            _Discovery.twitter_id = item["user"]["id_str"].ToString();
                            _Discovery.profile_image_url = item["user"]["profile_image_url"].ToString();
                            _Discovery.screan_name = item["user"]["screen_name"].ToString();
                            _Discovery.name = item["user"]["name"].ToString();
                            _Discovery.description = item["user"]["description"].ToString();
                            _Discovery.followers_count = item["user"]["followers_count"].ToString();
                            _Discovery.friends_count = item["user"]["friends_count"].ToString();

                            lstDiscovery.Add(_Discovery);
                        }
                        catch { }
                    }
                }
                catch { }
                return new JavaScriptSerializer().Serialize(lstDiscovery);
            }
            catch (Exception ex)
            {
                return new JavaScriptSerializer().Serialize(new List<Domain.Socioboard.Helper.Discovery>());
            }
        }
开发者ID:socioboard,项目名称:socioboard-core,代码行数:75,代码来源:DiscoverySearch.asmx.cs

示例11: GetResponse

        // TODO: Comment
        protected async Task<string> GetResponse(string urlApiService, string methodName, SortedDictionary<string, string> requestParameters)
        {
            // Parameters validation
            if (string.IsNullOrEmpty(urlApiService))
            {
                throw new ArgumentNullException("Null urlApiService.");
            }
            if (string.IsNullOrEmpty(methodName))
            {
                throw new ArgumentNullException("Null methodName.");
            }
            if (requestParameters == null)
            {
                throw new ArgumentNullException("Null requestParameters.");
            }

            // Execute
            string authHeader = CreateHeader(urlApiService, methodName, requestParameters);

            string resultString = string.Empty;
            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Accept.Clear();
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth", authHeader);
                string resourceUrl = string.Empty;
                if (requestParameters.Count > 0)
                {
                    resourceUrl = string.Concat(urlApiService, "?", requestParameters.ToWebString());
                }
                else
                {
                    resourceUrl = urlApiService;
                }
                HttpRequestMessage request = new HttpRequestMessage()
                {
                    RequestUri = new Uri(resourceUrl),
                    Method = methodName.Equals("GET") ? HttpMethod.Get : HttpMethod.Post
                };

                HttpResponseMessage response = await httpClient.SendAsync(request);
                resultString = await response.Content.ReadAsStringAsync();
                if (!response.IsSuccessStatusCode)
                {
                    dynamic errorMessageJson = Json.Decode(resultString);
                    ErrorMessage = ((dynamic)errorMessageJson).errors[0].message;
                }
            }

            return resultString;
        }
开发者ID:CaoDuyThanh,项目名称:ASP.NET-Sample,代码行数:52,代码来源:ServiceConnection.cs

示例12: CreateOauthSignature

        /// <summary>
        /// Generate an Oauth 1.0a HMAC-SHA1 signature for a HTTP request. This signature will be used for passing
        /// to the Twitter API as part of an authorized request.
        /// </summary>
        /// <param name="urlApiService"></param>
        /// <param name="method"></param>
        /// <param name="oauthNonce"></param>
        /// <param name="oauthTimestamp"></param>
        /// <param name="requestParameters"></param>
        /// <returns></returns>
        private string CreateOauthSignature(string urlApiService, string method, string oauthNonce, string oauthTimestamp, IDictionary<string, string> requestParameters)
        {
            // Execute
            SortedDictionary<string, string> signatureParameters = new SortedDictionary<string, string>(requestParameters);
            signatureParameters.Add("oauth_consumer_key", oauthConsumerKey);
            signatureParameters.Add("oauth_nonce", oauthNonce);
            signatureParameters.Add("oauth_signature_method", oauthSignatureMethod);
            signatureParameters.Add("oauth_timestamp", oauthTimestamp);
            signatureParameters.Add("oauth_token", oauthAccessToken);
            signatureParameters.Add("oauth_version", oauthVersion);

            string signatureParameterWebString = signatureParameters.ToWebString();
            string baseSignature = string.Concat(method, "&", Uri.EscapeDataString(urlApiService), "&", Uri.EscapeDataString(signatureParameterWebString));

            string signingKey = string.Concat(Uri.EscapeDataString(oauthConsumerKeySecret),
                                              "&",
                                              Uri.EscapeDataString(oauthAccessTokenSecret));

            string oauthSignature = String.Empty;
            oauthSignature = Hmacsha1Encode(baseSignature, signingKey);

            return oauthSignature;
        }
开发者ID:CaoDuyThanh,项目名称:ASP.NET-Sample,代码行数:33,代码来源:ServiceConnection.cs

示例13: TwitterHashTagSearchWithMaxTweetId

        public string TwitterHashTagSearchWithMaxTweetId(string Hashtag, string MaxTweetId)
        {
            Hashtag = Uri.EscapeUriString(Hashtag);
            Hashtag = Hashtag.Replace("%20%E2%80%8E", string.Empty);
            JArray output = new JArray();
            try
            {
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                //requestParameters.Add("user_id", UserId);
                //requestParameters.Add("screen_name", Hashtag);
                //requestParameters.Add("count", "198");
                //Token URL
                var oauth_url = string.Empty;
                if (!string.IsNullOrEmpty(MaxTweetId))
                {
                    oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=%23" + Hashtag.TrimStart() + "&result_type=mixed&count=95&max_id=" + MaxTweetId.ToString();
                }
                else
                {
                    oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=%23" + Hashtag.TrimStart() + "&result_type=mixed";
                }

                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAEB7gwAAAAAA2Jk7qBC%2BWVA5tHGEoNn2Z9bayGU%3DNn0MsaxfRaMIsZ0b5UeHymBwl61Sc9TjBR0FokROqonw5a1t3F");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());

                }
            }
            catch (Exception ee) { }

            return output.ToString();
        }
开发者ID:socioboard,项目名称:socioboard-core,代码行数:49,代码来源:Companypage.asmx.cs

示例14: TwitterBoardHashTagSearch

        public string TwitterBoardHashTagSearch(string Hashtag, string LastTweetId)
        {
            Hashtag = Uri.EscapeUriString(Hashtag);
            Hashtag = Hashtag.Replace("%20%E2%80%8E", string.Empty);
            JArray output = new JArray();
            try
            {
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                //requestParameters.Add("user_id", UserId);
                //requestParameters.Add("screen_name", Hashtag);
                //requestParameters.Add("count", "198");
                //Token URL
                var oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=%23" + Hashtag.TrimStart() + "&result_type=mixed&count=95";
                if (!string.IsNullOrEmpty(LastTweetId))
                {
                    oauth_url = oauth_url + "&since_id=" + LastTweetId;
                }
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAKFPggAAAAAArwWHS2FBX%2FkwQQa40yoy3yLxP0Y%3DQW1M1gGoVK1b4WLdQ8gg0lMB7m4gPnAzDTNijQENJrKVocyBfX");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());

                }
            }
            catch (Exception ee) { }

            return output.ToString();
        }
开发者ID:socioboard,项目名称:socioboard-core,代码行数:44,代码来源:Companypage.asmx.cs

示例15: TwitterUserTimeLine

        public string TwitterUserTimeLine(string ScreenName)
        {
            JArray output = new JArray();
            try
            {
                SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
                //requestParameters.Add("user_id", UserId);
                requestParameters.Add("screen_name", ScreenName);
                requestParameters.Add("count", "198");
                //Token URL
                var oauth_url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAOZyVwAAAAAAgI0VcykgJ600le2YdR4uhKgjaMs%3D0MYOt4LpwCTAIi46HYWa85ZcJ81qi0D9sh8avr1Zwf7BDzgdHT");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(objText);

                }
            }
            catch (Exception ee) { }

            return output.ToString();
        }
开发者ID:prog-moh,项目名称:socioboard-core,代码行数:38,代码来源:CompanyProfiles.cs


注:本文中的SortedDictionary.ToWebString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。