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


C# RestClient.Request方法代码示例

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


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

示例1: fetchXml

        public void fetchXml()
        {
            User = usernamBox.Text.Replace(" ", "").Replace("/", "").Replace(".", "");
            URL = new Uri("http://" + User + ".tumblr.com/api/read/json");

            int max = 0;
            var client = new RestClient();
            client.Authority = URL.ToString();
            var request = new RestRequest();
            request.AddParameter("type", "photo");
            request.AddParameter("num", "50");
            request.AddParameter("filter", "text");
            var r1 = client.Request(request);
            var t = r1.Content.ToString().Replace("var tumblr_api_read = ", "");
            var firstResponse = JsonParser.FromJson(t);
            max = Convert.ToInt32(firstResponse["posts-total"]);
            // to eventually make each fetch a separate request
            for (int i = 0; i < max; i += 51)
            {
                if (i != 0)
                {
                    request.AddParameter("start", i.ToString());
                }
                var r2 = client.Request(request);
                var t2 = r2.Content.ToString().Replace("var tumblr_api_read = ", "");
                var Response = JsonParser.FromJson(t2);

                getUrls(Response.ToDictionary(x => x.Key, x => x.Value));
            }
        }
开发者ID:aviatrix,项目名称:tumblr-downloader,代码行数:30,代码来源:Form1.cs

示例2: RetrieveTweets

        private static string RetrieveTweets(string sinceId)
        {
            BasicAuthCredentials credentials = new BasicAuthCredentials
                                                   {
                                                       Username = WebConfigurationManager.AppSettings["ScreenName"],
                                                       Password = WebConfigurationManager.AppSettings["SuperTweetPassword"]
                                                   };
            RestClient client = new RestClient
                                    {
                                        Authority = "http://api.supertweet.net",
                                        VersionPath = "1"
                                    };

            string possibleSinceId = string.IsNullOrWhiteSpace(sinceId) ? "": string.Format("&since_id={0}", sinceId) ;

            RestRequest request = new RestRequest
                                      {
                                          Credentials = credentials,
                                          Path = string.Format("statuses/home_timeline.json?count=200&include_entities=false{0}", possibleSinceId)
                                      };
            RestResponse response = client.Request(request);

            var content = response.Content;
            return content;
        }
开发者ID:zdam,项目名称:BatchedTweets,代码行数:25,代码来源:HomeController.cs

示例3: Index

        public ActionResult Index()
        {
            var restConfig = RestConfig.Current;
            if (string.IsNullOrEmpty(restConfig.UserId))
                return RedirectToAction("Authorize");

            var client = new RestClient {Authority = restConfig.BaseUrl};
            var request = new RestRequest
                              {
                                  Path = string.Format("users/{0}/queues/instant", restConfig.UserId),
                                  Credentials = OAuthCredentials.ForProtectedResource(
                                      restConfig.OAuthKey, restConfig.OAuthSharedSecret,
                                      restConfig.OAuthToken, restConfig.OAuthTokenSecret)
                              };
            var response = client.Request(request);
            if (response.StatusCode == HttpStatusCode.OK)
            {
                var xml = XDocument.Parse(response.Content);
                var items = from i in xml.Descendants("queue_item")
                            select new Movie
                                       {
                                           Title = (string) i.Descendants("title").Attributes("regular").FirstOrDefault(),
                                           Thumbnail = (string)i.Descendants("box_art").Attributes("small").FirstOrDefault(),
                                           ReleaseYear = (string)i.Descendants("release_year").FirstOrDefault(),
                                           Link = (string)i.Descendants("link").Where(x => (string) x.Attribute("rel") == "alternate").Attributes("href").FirstOrDefault()
                                       };
                var model = new {Response = response, Items = items}.ToExpando();
                return View(model);
            }
            return View(new {Response = response, Items = (object) null}.ToExpando());
        }
开发者ID:NashDotNet,项目名称:RestSamples,代码行数:31,代码来源:NetflixController.cs

示例4: GetFavorites

        public RestResponse GetFavorites(string user, int page, int pageSize)
        {
            // Documentation for GET /favorites
            // https://dev.twitter.com/docs/api/1/get/favorites

            // Create the REST Client
            var client = new RestClient {Authority = "http://api.twitter.com/1"};

            // Create the REST Request
            var request = new RestRequest {Path = "favorites.json", Method = WebMethod.Get};
            request.AddParameter("id", user);
            request.AddParameter("page", page.ToString());
            request.AddParameter("count", pageSize.ToString());

            // Set API authentication tokens
            var appSettings = ConfigurationManager.AppSettings;
            request.Credentials = OAuthCredentials.ForProtectedResource(
                appSettings["ConsumerKey"], appSettings["ConsumerSecret"], appSettings["Token"],
                appSettings["TokenSecret"]);

            // Make request
            var response = client.Request(request);

            return response;
        }
开发者ID:NashDotNet,项目名称:RestSamples,代码行数:25,代码来源:TwitterSamples.cs

示例5: MakeYahooPostSample

        public string MakeYahooPostSample()
        {
            var client = new RestClient
                         	{
                         		Authority = "http://api.search.yahoo.com/ContentAnalysisService",
                         		VersionPath = "V1"
                         	};
            var request = new RestRequest
                          	{
                          		Path = "termExtraction",
                                Method = WebMethod.Post
                          	};

            var appId = "YahooDemo";
            var context = "Italian sculptors and painters of the renaissance favored the Virgin Mary for inspiration";
            var query = "madonna";

            request.AddField("appid", appId);
            request.AddField("context", context);
            request.AddField("query", query);

            var response = client.Request(request);

            return response.Content;
        }
开发者ID:NashDotNet,项目名称:RestSamples,代码行数:25,代码来源:HammockSamples.cs

示例6: UpdateStatus

        /// <summary>
        /// ステータスを更新します
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="accessTokenSecret"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static dynamic UpdateStatus(string accessToken, string accessTokenSecret, string message)
        {
            var client = new RestClient
            {
                Authority = "http://api.twitter.com",
                UserAgent = "OAuthSample",
            };

            var credentials = OAuthCredentials.ForProtectedResource(
                Config.TwitterConsumerKey,
                Config.TwitterConsumerSecret,
                accessToken,
                accessTokenSecret);
            credentials.ParameterHandling = OAuthParameterHandling.UrlOrPostParameters;

            var request = new RestRequest
            {
                Path = "statuses/update.json",
                Method = WebMethod.Post,
                Credentials = credentials,
            };

            request.AddParameter("status", message);

            var response = client.Request(request);
            return DynamicJson.Parse(response.Content);
        }
开发者ID:masaedw,项目名称:OAuthSample,代码行数:34,代码来源:Twitter.cs

示例7: GetTwitterRedirectUrl

        public string GetTwitterRedirectUrl(string consumerKey, string consumerSecret, string CallBackUrl)
        {
            OAuthCredentials credentials = new OAuthCredentials()
            {
                Type = OAuthType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                ConsumerKey = consumerKey,
                ConsumerSecret = consumerSecret,
                CallbackUrl = CallBackUrl
            };

            // Use Hammock to create a rest client
            var client = new RestClient
            {
                Authority = "https://api.twitter.com/oauth",
                Credentials = credentials
            };

            // Use Hammock to create a request
            var request = new RestRequest
            {
                Path = "request_token"
            };

            // Get the response from the request
            var response = client.Request(request);

            var collection = HttpUtility.ParseQueryString(response.Content);
            //string str = collection[1].ToString();
            //HttpContext.Current.Session["requestSecret"] = collection[1];
            string rest = "https://api.twitter.com/oauth/authorize?oauth_token=" + collection[0] + "~" + collection[1];

            return rest;
        }
开发者ID:NALSS,项目名称:socioboard,代码行数:35,代码来源:Twitter.asmx.cs

示例8: GetUserInformation

        /// <summary>
        /// ログインユーザ情報を取得します
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public static dynamic GetUserInformation(string accessToken)
        {
            // see http://developers.facebook.com/docs/reference/api/user/

            var client = new RestClient { Authority = "https://graph.facebook.com/" };
            var request = new RestRequest { Path = "me" };
            request.AddParameter("access_token", accessToken);
            var response = client.Request(request);
            return DynamicJson.Parse(response.Content);
        }
开发者ID:masaedw,项目名称:OAuthSample,代码行数:15,代码来源:Facebook.cs

示例9: TweetImage

        public RestResponse TweetImage(string imagePath, string imageName)
        {
            Hammock.RestRequest request = service.PrepareEchoRequest();
            request.Path = "uploadAndPost.xml";
            request.AddFile("media", imageName, imagePath, "image/jpeg");
            request.AddField("key", "bb5654b0649cb63672affff5a232d772");
            request.AddField("message", "ODE Bot at it again");

            // Post photo to TwitPic with Hammock
            RestClient client = new RestClient { Authority = "http://api.twitpic.com/", VersionPath = "2" };
            RestResponse response = client.Request(request);

            return response;
        }
开发者ID:joshp123,项目名称:ODESolver,代码行数:14,代码来源:Tweeter.cs

示例10: CreateLoginUsersStatusMessage

        /// <summary>
        /// ログインユーザのステータスメッセージを更新します
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static dynamic CreateLoginUsersStatusMessage(string accessToken, string message)
        {
            // see http://developers.facebook.com/docs/reference/api/user/

            var client = new RestClient { Authority = "https://graph.facebook.com/" };
            var request = new RestRequest
            {
                Path = "me/feed",
                Method = Hammock.Web.WebMethod.Post,
            };
            request.AddParameter("access_token", accessToken);
            request.AddParameter("message", message);
            var response = client.Request(request);
            return DynamicJson.Parse(response.Content);
        }
开发者ID:masaedw,项目名称:OAuthSample,代码行数:21,代码来源:Facebook.cs

示例11: Callback

        public ActionResult Callback()
        {
            token = Request["oauth_token"];
            verifier = Request["oauth_verifier"];
            var credentials = new OAuthCredentials
            {
                ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"],
                ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"],
                Token = token,
                TokenSecret = token_secret,
                Verifier = verifier,
                Type = OAuthType.AccessToken,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Version = "1.0"
            };

            var client = new RestClient { Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials, Method = WebMethod.Post };
            var request = new RestRequest { Path = "accessToken" };
            RestResponse response = client.Request(request);
            string content = response.Content;

            string accessToken = response.Content.Split('&').Single(s => s.StartsWith("oauth_token=")).Split('=')[1];
            string accessTokenSecret = response.Content.Split('&').Single(s => s.StartsWith("oauth_token_secret=")).Split('=')[1];

            //string accessToken = response.Content.Split('&amp;').Where(s = &gt; s.StartsWith("oauth_token=")).Single().Split('=')[1];
            //string accessTokenSecret = response.Content.Split('&amp;').Where(s = &gt; s.StartsWith("oauth_token_secret=")).Single().Split('=')[1];

            //var company = new LinkedInService(accessToken, accessTokenSecret).GetCompany(162479);

            // Some commented call to API
            //company = new LinkedInService(accessToken, accessTokenSecret).GetCompanyByUniversalName("linkedin");
            //  var companies = new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByEmailDomain("apple.com");
            // var companies1 = new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByEmailDomain("linkedin.com");
            // var companies2= new LinkedInService(accessToken, accessTokenSecret).GetCompaniesByIdAnduniversalName("162479", "linkedin");
            //var people = new LinkedInService(accessToken, accessTokenSecret).GetPersonById("f7cp5sKscd");
            //var people = new LinkedInService(accessToken, accessTokenSecret).GetCurrentUser();

            //string url = Url.Encode("http://bd.linkedin.com/pub/rakibul-islam/37/522/653");
            //var people = new LinkedInService(accessToken, accessTokenSecret).GetPeoPleByPublicProfileUrl(url);
            //var peopleSearchresult = new LinkedInService(accessToken, accessTokenSecret).SearchPeopleByKeyWord("Princes");

            //var peopleSearchresult = new LinkedInService(accessToken, accessTokenSecret).GetPeopleByFirstName("Mizan");
            var currUser = new LinkedInService(accessToken,accessTokenSecret).GetCurrentUser();
            //String companyName = company.Name;
            return Content($"{currUser.FirstName} {currUser.LastName} {currUser.headLine}");
        }
开发者ID:yrikturash,项目名称:linkedinservice,代码行数:47,代码来源:LinkedinController.cs

示例12: Can_use_specification_validation_to_block_request

        public void Can_use_specification_validation_to_block_request()
        {
            var info = new DateTimeFormatInfo { Email = "nowhere" };

            var client = new RestClient
            {
                Authority = "http://nowhere.com",
                Info = info
            };

            var request = new RestRequest
            {
                Path = "fast"
            };

            client.Request(request);
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:17,代码来源:SpecificationAttributeTests.cs

示例13: Can_use_boolean_to_integer_validation_to_transform_parameter_value

        public void Can_use_boolean_to_integer_validation_to_transform_parameter_value()
        {
            var info = new BooleanToIntegerInfo {IShouldBeANumber = false};

            var client = new RestClient
                             {
                                 Authority = "http://nowhere.com",
                                 Info = info
                             };

            var request = new RestRequest
                              {
                                  Path = "fast"
                              };

            client.Request(request);
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:17,代码来源:BooleanToIntegerTests.cs

示例14: Can_use_date_time_validation_to_transform_header_value

        public void Can_use_date_time_validation_to_transform_header_value()
        {
            var info = new DateTimeFormatInfo {IAmADate = DateTime.Now };

            var client = new RestClient
                             {
                                 Authority = "http://nowhere.com",
                                 Info = info
                             };

            var request = new RestRequest
                              {
                                  Path = "fast"
                              };

            client.Request(request);
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:17,代码来源:DateTimeFormatTests.cs

示例15: getFacebookData

    void getFacebookData()
    {
        string CallbackUrl = "http://localhost:27393/facebookyeni/callback.aspx";
        var client = new RestClient { Authority = "https://graph.facebook.com/oauth/" };
        var request = new RestRequest { Path = "access_token" };

        request.AddParameter("client_id", ConfigurationManager.AppSettings["FacebookClientId"]);
        request.AddParameter("redirect_uri", CallbackUrl);
        request.AddParameter("client_secret", ConfigurationManager.AppSettings["FacebookApplicationSecret"]);
        request.AddParameter("code", Request["code"]);

        RestResponse response = client.Request(request);
        StringDictionary result = FacebookConnect.ParseQueryString(response.Content);
        string aToken = result["access_token"];

        responseFacebookUserInfo(aToken);
    }
开发者ID:webyonet,项目名称:facebookApi,代码行数:17,代码来源:callback.aspx.cs


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