• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Hammock.RestRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RestRequest类属于Hammock命名空间,在下文中一共展示了RestRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetTwitterToken

        private void GetTwitterToken()
        {
            var credentials = new OAuthCredentials
            {
                Type = OAuthType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                ConsumerKey = Constants.ConsumerKey,
                ConsumerSecret = Constants.ConsumerKeySecret,
                Version = Constants.OAuthVersion,
                CallbackUrl = Constants.CallbackUri
            };
            var client = new RestClient
            {
                Authority = "https://api.twitter.com/oauth",
                Credentials = credentials,
                HasElevatedPermissions = true,
                SilverlightAcceptEncodingHeader = "gizp",
                DecompressionMethods = DecompressionMethods.GZip,
            };

            var request = new RestRequest
            {
                Path = "/request_token"
            };
            client.BeginRequest(request, new RestCallback(TwitterRequestTokenCompleted));
        }
开发者ID:CodeObsessed,项目名称:drumbleapp,代码行数:27,代码来源:TwitterAuthPage.xaml.cs


示例2: newFoodLogEntryCallback

        private void newFoodLogEntryCallback(RestRequest request, Hammock.RestResponse response, object obj)
        {
            if (response.StatusCode == HttpStatusCode.Created ||
                response.StatusCode == HttpStatusCode.OK)
            {
                Dispatcher.BeginInvoke(()=>
                txtProgressMessage.Text = dbwp7Resources.Success);
            }
            else
                Dispatcher.BeginInvoke(()=>
                txtProgressMessage.Text = dbwp7Resources.CouldNotSave);

            System.Threading.Thread.Sleep(800);

            Dispatcher.BeginInvoke(() =>
            {
                spProcessing.Visibility = Visibility.Collapsed;
                txtProgressMessage.Text = dbwp7Resources.Processing;
            });

            if (FoodEntryLogged != null)
                FoodEntryLogged(this, new RoutedEventArgs());

          
        }
开发者ID:mmydland,项目名称:burntracker,代码行数:25,代码来源:RecordFood.xaml.cs


示例3: Main

        public static void Main(string[] args)
        {
            if(args.Length == 0)
            {
                PrintUsage();
                return;
            }

            if(args.Length == 1)
            {
                Uri uri;
                if(Uri.TryCreate(args[0], UriKind.Absolute, out uri))
                {
                    _client.Authority = uri.Scheme + "://" + uri.Authority;
                    var request = new RestRequest { Path = uri.PathAndQuery };
                    var response = _client.Request(request);
                    response.Content.Out();
                    return;
                }
                else
                {
                    
                }
            }
        }
开发者ID:BigBadChicago,项目名称:hammock,代码行数:25,代码来源:Program.cs


示例4: GetFriends

 public static void GetFriends(EventHandler<FriendsListEventArgs> callback)
 {
     var serializer = new Hammock.Serialization.HammockDataContractJsonSerializer();
     RestClient client = new RestClient
     {
         Authority = baseUrl,
         Timeout = new TimeSpan(0, 0, 0, _timeOut),
         Serializer = serializer,
         Deserializer = serializer
     };
     RestRequest request = new RestRequest
                               {
                                   Path = "GetFriends" + "?timestamp=" + DateTime.Now.Ticks.ToString(),
                                   Timeout = new TimeSpan(0, 0, 0, _timeOut)
                               };
     friendscallback = callback;
     try
     {
         client.BeginRequest(request, new RestCallback<List<Friend>>(GetFriendsCallback));
     }
     catch (Exception ex)
     {
         friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = null, Error = new WebException("Communication Error!", ex) });
     }
     
 }
开发者ID:253525306,项目名称:myfriendsaround,代码行数:26,代码来源:ServiceAgent.cs


示例5: PhotoPostCompleted

 private void PhotoPostCompleted(RestRequest request, RestResponse response, object userstate)
 {
     // We want to ensure we are running on our thread UI
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         if (response.StatusCode == HttpStatusCode.Created)
         {
             Deployment.Current.Dispatcher.BeginInvoke(
                 () =>
                 {
                     ToastPrompt toast = new ToastPrompt
                     {
                         Title = "ajapaik",
                         Message = "your photo was uploaded",
                     };
                     toast.Show();
                 });
         }
         else
         {
             MessageBox.Show("Error while uploading to server. Please try again later. " +
                     "If this error persists please let the program author know.");
         }
     });
 }
开发者ID:Ajapaik,项目名称:ajapaik-wp7,代码行数:25,代码来源:AcceptPhotoView.xaml.cs


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


示例7: PostCompleted

        /**
         * ASync callback for posting a new photo
         **/
        public void PostCompleted(RestRequest request, RestResponse response, object target)
        {
            Dispatcher.BeginInvoke(() => this.postProgress.Visibility = System.Windows.Visibility.Collapsed);
            this.isPosting = false;
            // HACK: This is kind of hacky...
            Dispatcher.BeginInvoke(() => ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                Dispatcher.BeginInvoke(() => {
                    MessageBox.Show("Photo Posted Successfully!");
                    this.captionTextbox.IsEnabled = true;

                    // Reset photo and caption
                    this.hasDefaultText = true;
                    this.captionTextbox.Text = "Enter a Caption...";
                    this.captionTextbox.TextAlignment = TextAlignment.Center;
                    this.captionTextbox.Foreground = this.Resources["InactiveTextBrush"] as Brush;

                    this.photo = null;
                    this.photoPreview.Source = new BitmapImage(new Uri("/Images/photo_icon.png", UriKind.Relative));
                    this.photoPreview.Stretch = Stretch.None;
                    this.photoPreview.SetValue(Canvas.MarginProperty, new Thickness(9, 69, 6, 0));
                });
            }
            else
            {
                Dispatcher.BeginInvoke(() => {
                    MessageBox.Show("Error Posting Photo: " + response.Content);
                    this.captionTextbox.IsEnabled = true; // Re-enable the text box
                });
            }
        }
开发者ID:tmrudick,项目名称:wp7-tumblr-photo-uploader,代码行数:36,代码来源:MainPage.xaml.cs


示例8: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            RestClient client2 = new RestClient
            {
                Authority = "https://graph.facebook.com/",
            };

            RestRequest request2 = new RestRequest
            {
                Path = "/me/feed?message=" + WatermarkTB.Text
            };
            if (imgstream != null)
            {
                string albumId = (string)settings["facebook_photo"];
                request2 = new RestRequest
                {
                    Path = albumId + "/photos?message=" + WatermarkTB.Text
                };
                request2.AddFile("photo", "image.jpg", imgstream);
            }
            request2.AddField("access_token", (string)settings["facebook_token"]);
            var callback = new RestCallback(
                (restRequest, restResponse, userState) =>
                {
                    // Callback when signalled
                }
                );
            client2.BeginRequest(request2, callback);

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


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


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


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


示例12: modifiedEntryCallback

 public void modifiedEntryCallback(RestRequest request, Hammock.RestResponse response, object obj)
 {
     if (response.StatusCode == HttpStatusCode.OK)
         Dispatcher.BeginInvoke(() => NavigationService.Navigate(new Uri("/JumpPage.xaml", UriKind.RelativeOrAbsolute)));
     else
         Dispatcher.BeginInvoke(() => MessageBox.Show(dbwp7Resources.FailedToDeleteTheEntry));
 }
开发者ID:mmydland,项目名称:burntracker,代码行数:7,代码来源:EditFoodLogEntry.xaml.cs


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


示例14: searchCallback

        private void searchCallback(RestRequest request, RestResponse response, object sender)
        {
            XmlReader rdr = XmlReader.Create(response.ContentStream);
            while (!rdr.EOF)
            {
                if (rdr.ReadToFollowing("exercise"))
                {
                    SearchedExercise exercise = new SearchedExercise();
                    rdr.ReadToFollowing("id");
                    exercise.id = rdr.ReadElementContentAsInt();
                    rdr.ReadToFollowing("name");
                    exercise.Name = rdr.ReadElementContentAsString();
                    rdr.ReadToFollowing("exercise-description");
                    exercise.Description = rdr.ReadElementContentAsString();
                    rdr.ReadToFollowing("exercise-type");
                    exercise.exercise_type = rdr.ReadElementContentAsString();
                    rdr.ReadToFollowing("exercise-video-url");
                    exercise.exercise_video_url = rdr.ReadElementContentAsString();
                    rdr.ReadToFollowing("exercise-picture-url");
                    exercise.PictureUrl = rdr.ReadElementContentAsString();
                    rdr.ReadToFollowing("exercise-order");
                    if (!rdr.MoveToAttribute("nil"))
                        exercise.exercise_order = rdr.ReadElementContentAsInt();
                    else
                        exercise.exercise_order = 0;

                    exercises.Add(exercise);
                }
            }

            OnSearchComplete();
        }
开发者ID:mmydland,项目名称:burntracker,代码行数:32,代码来源:DailyBurnExcerciseList.cs


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


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


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


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


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


示例20: mealListGetCallback

        private void mealListGetCallback(RestRequest request, Hammock.RestResponse response, object obj)
        {
            DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(MealNames[]));
            meals = json.ReadObject(response.ContentStream) as MealNames[];

            if (MealListLoaded != null)
                MealListLoaded(this, new EventArgs());

        }
开发者ID:mmydland,项目名称:burntracker,代码行数:9,代码来源:DailyBurnMealList.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.EncodeTask类代码示例发布时间:2022-05-26
下一篇:
C# Meta.Meta类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap