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


C# RestRequest.AddParameter方法代码示例

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


在下文中一共展示了RestRequest.AddParameter方法的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: AddComments

        public void AddComments(String id, String text, CompleteHandler handler)
        {
            if (m_netEngine == null)
                m_netEngine = new DoubanNetEngine();
            RestRequest request = new RestRequest();
            request.Method = WebMethod.Post;
            request.Path = String.Format("shuo/v2/statuses/{0}/comments", id);
            request.AddParameter("text", text);
            request.AddParameter("source", DoubanSdkData.AppKey);

            m_netEngine.SendRequest(request, (DoubanSdkResponse response) =>
            {
                if (response.errCode == DoubanSdkErrCode.SUCCESS)
                {
                    DoubanEventArgs args = new DoubanEventArgs();
                    args.errorCode = DoubanSdkErrCode.SUCCESS;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
                else
                {
                    DoubanEventArgs args = new DoubanEventArgs();
                    args.errorCode = response.errCode;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
            });
        }
开发者ID:thankcreate,项目名称:Care,代码行数:28,代码来源:ShuoAPI.cs

示例3: 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

示例4: BeginUserRealtimeLinks

        public void BeginUserRealtimeLinks(BitlyLogin user, RestCallback callback)
        {
            var request = new RestRequest {Path = "user/realtime_links"};
            request.AddParameter("format", "json");
            request.AddParameter("access_token", user.access_token);

            _sslClient.BeginRequest(request, callback);
        }
开发者ID:Aaronontheweb,项目名称:bitlytracker,代码行数:8,代码来源:BitlyService.cs

示例5: BeginGetAccessToken

        public void BeginGetAccessToken(string code, RestCallback callback)
        {
            var oauthClient = new RestClient {Authority = _sslClient.Authority};

            //Build an OAuth request manually - the Bit.ly documentation didn't indicate that I needed signatures
            var request = new RestRequest {Method = WebMethod.Post, Path = "/oauth/access_token"};

            request.AddParameter("client_id", Settings.ConsumerKey);
            request.AddParameter("client_secret", Settings.ConsumerSecret);
            request.AddParameter("code", code);
            request.AddParameter("redirect_uri", Settings.RedirectUrl);

            oauthClient.BeginRequest(request, callback);
        }
开发者ID:Aaronontheweb,项目名称:bitlytracker,代码行数:14,代码来源:BitlyService.cs

示例6: 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

示例7: GetComments

        public void GetComments(String id, int count, GetCommentsCompleteHandler handler)
        {
            if (m_netEngine == null)
                m_netEngine = new DoubanNetEngine();
            RestRequest request = new RestRequest();
            request.Method = WebMethod.Get;
            request.Path = String.Format("shuo/v2/statuses/{0}/comments", id);
            request.AddParameter("count", count.ToString());

            m_netEngine.SendRequest(request, (DoubanSdkResponse response) =>
            {
                if (response.errCode == DoubanSdkErrCode.SUCCESS)
                {
                    GetCommentsEventArgs args = new GetCommentsEventArgs();
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<Comment>));
                    List<Comment> list = ser.ReadObject(response.stream) as List<Comment>;
                    args.comments = list;
                    args.errorCode = DoubanSdkErrCode.SUCCESS;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
                else
                {
                    GetCommentsEventArgs args = new GetCommentsEventArgs();
                    args.comments = null;
                    args.errorCode = response.errCode;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
            });
        }
开发者ID:thankcreate,项目名称:Care,代码行数:31,代码来源:ShuoAPI.cs

示例8: 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

示例9: 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

示例10: SendRequest

        public void SendRequest(RestRequest request, RequestBack callBack)
        {
            Action<string> errAction = (e1) =>
            {
                if (null != callBack)
                {
                    DoubanSdkErrCode sdkErr = DoubanSdkErrCode.XPARAM_ERR;
                    callBack(new DoubanSdkResponse
                    {
                        //requestID = null != data ? data.requestId : "",
                        errCode = sdkErr,
                        specificCode = "",
                        content = e1,
                        stream = null
                    });
                }
            };

            if (null == request)
            {
                errAction("request should`t be null.");
                return;
            }

            m_Client.Authority = ConstDefine.PublicApiUrl;
            m_Client.HasElevatedPermissions = true;

            //添加鉴权
            request.DecompressionMethods = DecompressionMethods.GZip;
            request.Encoding = Encoding.UTF8;

            IWebCredentials credentials = null;

            if (null != DoubanAPI.DoubanInfo.tokenInfo && !string.IsNullOrEmpty(DoubanAPI.DoubanInfo.tokenInfo.access_token))
            {
                request.AddHeader("Authorization", string.Format("Bearer {0}", DoubanAPI.DoubanInfo.tokenInfo.access_token));
            }
            else
            {
                request.AddParameter("source", DoubanSdkData.AppKey);
            }
            request.AddParameter("curtime", DateTime.Now.ToString());
            request.Credentials = credentials;

            m_Client.BeginRequest(request, (e1, e2, e3) => AsyncCallback(e1, e2, callBack));
        }
开发者ID:thankcreate,项目名称:Care,代码行数:46,代码来源:DoubanNetEngine.cs

示例11: CreateTokensRequest

        protected override RestRequest CreateTokensRequest(NameValueCollection parameters)
        {
            var request = new RestRequest
            {
                Path = "/1/oauth2/token.json",
                Method = Hammock.Web.WebMethod.Post,

            };

            request.AddParameter("client_id", SensitiveData.BufferClientId);
            request.AddParameter("client_secret", SensitiveData.BufferClientSecret);
            request.AddParameter("redirect_uri", callbackUrl);
            request.AddParameter("code", parameters["code"]);
            request.AddParameter("grant_type", "authorization_code");

            return request;
        }
开发者ID:rafaelwinter,项目名称:Ocell,代码行数:17,代码来源:BufferOAuthModel.cs

示例12: 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

示例13: CallbackFacebook

        public ActionResult CallbackFacebook(string code)
        {
            if (String.IsNullOrEmpty(code))
            {
                // TempData is equivalent to flash of rails.
                TempData["message"] = "認証に失敗しました";
                return RedirectToAction("Login");
            }

            var client = new RestClient
            {
                Authority = "https://graph.facebook.com/oauth/",
            };

            var request = new RestRequest
            {
                Path = "access_token",
            };

            request.AddParameter("client_id", Config.FacebookAppId);
            request.AddParameter("redirect_uri", Config.ApplicationUrl + "/Account/CallbackFacebook");
            request.AddParameter("client_secret", Config.FacebookAppSecret);
            request.AddParameter("code", code);

            var response = client.Request(request);

            // response contains access_token and expires
            var result = HttpUtility.ParseQueryString(response.Content);

            // to handle expired access tokens, see the blog
            // https://developers.facebook.com/blog/post/500/

            var accessToken = result["access_token"];
            var user = (User)Session["user"] ?? new User();

            user.FacebookAccessToken = accessToken;
            user.FacebookUser = Facebook.GetUserInformation(accessToken);

            Session["user"] = user;

            return RedirectToAction("Index", "Tubuyaki");
        }
开发者ID:masaedw,项目名称:OAuthSample,代码行数:42,代码来源:AccountController.cs

示例14: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            string auth_key = String.Format("full_auth_token {0}", settings["me2day_token"]);
            IWebCredentials credentials = new BasicAuthCredentials
            {
                Username = (string)settings["me2day_userid"],
                Password = auth_key
            };

            RestClient client = new RestClient
            {
                Authority = "http://me2day.net/api/"
            };

            RestRequest request = new RestRequest
            {
                Credentials = credentials,
                Path = String.Format("create_post/{0}.xml?akey=aed420d038f9b1a7fe3b5c0d94df22f5", settings["me2day_userid"])
            };
            request.AddParameter("post[body]", WatermarkTB.Text);
            request.AddParameter("post[tags]", WatermarkTB2.Text);

            if (imgstream != null)
            {
                request.AddFile("attachment", "image.jpg", imgstream, "image/jpeg");
            }

            var callback = new RestCallback(
                (restRequest, restResponse, userState) =>
                {
                    // Callback when signalled
                }
            );

            client.BeginRequest(request, callback);

            MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
            this.NavigationService.GoBack();
        }
开发者ID:vapps,项目名称:HDStream,代码行数:39,代码来源:Me2dayWrite.xaml.cs

示例15: DoRequest

        //protected void DoRequest(string sEndpoint, WebMethod wmTransferType, Dictionary<string, string> dssParams, APIReturn aprReturn)
        protected void DoRequest(RestRequest rrRequest, OAuthCredentials oaCredentials, APIReturn aprReturn)
        {
            //suggested by the smart guys at dev.twitter.com
            rrRequest.AddParameter("oauth_callback", "oob");

            RestClient rcClient = new RestClient
            {
                Authority = C_OAUTH_BASE_URL,
                Credentials = oaCredentials
            };

            //post request, update credentials object
            rcClient.BeginRequest(rrRequest, DoRequestCallback, aprReturn);
        }
开发者ID:camertron,项目名称:twitter-windows,代码行数:15,代码来源:OAuthAPI.cs


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