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


C# RestRequest.AddField方法代码示例

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


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

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

示例2: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (WatermarkTB.Text == emptystr)
            {
                MessageBox.Show("Please input your mind :)", "Sorry", MessageBoxButton.OK);
                return;
            }
            RestClient client2 = new RestClient
            {
                Authority = "https://graph.facebook.com/",
            };

            RestRequest request2 = new RestRequest
            {
                Path = id+"/comments?message=" + WatermarkTB.Text
            };

            request2.AddField("access_token", (string)settings["facebook_token"]);
            var callback = new RestCallback(
                (restRequest, restResponse, userState) =>
                {
                    Dispatcher.BeginInvoke(delegate()
                    {
                        ScrollViewer.Height = 680;
                        ScrollViewer.UpdateLayout();
                        ScrollViewer.ScrollToVerticalOffset(double.MaxValue);
                        WatermarkTB.Text = emptystr;
                        keyboard.txt = "";
                        keyboard.Init();
                        KeyboardPanel.Visibility = Visibility.Collapsed;
                        comment_list.Children.Clear();
                        loadpg.Visibility = Visibility.Visible;
                        SolidColorBrush Brush1 = new SolidColorBrush();
                        Brush1.Color = Colors.Gray;
                        WatermarkTB.Foreground = Brush1;
                    });

                    string url = String.Format("https://graph.facebook.com/{0}?access_token={1}", id, (string)settings["facebook_token"]);
                    WebClient wc = new WebClient();
                    wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler);
                    wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
                }
                );
            client2.BeginRequest(request2, callback);
        }
开发者ID:vapps,项目名称:HDStream,代码行数:45,代码来源:FacebookPostView.xaml.cs

示例3: LoginAsync

        public void LoginAsync(string email,
            string password, Action<LoginInfo> report)
        {
            var request = new RestRequest
            {
                Path = "token",
                Method = WebMethod.Post,
            };
            request.AddField("email", email);
            request.AddField("password", password);
            request.AddField("oauth_signature_method", "HMAC-SHA1");
            request.AddField("oauth_consumer_key", DropBoxInfo.KEY);

            ClearAuthenticator();
            _client.BeginRequest<LoginInfo>(request, (req, res, state) =>
            {
                if (res.StatusCode != HttpStatusCode.OK)
                {
                    report(null);
                    return;
                }

                var data = res.ContentEntity;
                InitAuthenticator(data.Token, data.Secret);
                report(data);
            });
        }
开发者ID:MarioBinder,项目名称:7Pass,代码行数:27,代码来源:Client.cs

示例4: photoChooserTask_Completed

        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                img_bool = true;
                var client = new RestClient
                {
                    Authority = "http://api.twipl.net/",
                    VersionPath = "1",
                };

                var request = new RestRequest
                {
                    Path = "upload.json" // can be upload.xml or whatever, but you have to parse it accordingly
                };

                request.AddFile("media1", "img.jpg", e.ChosenPhoto);
                request.AddField("key", "b76ecda29f7c47e0bfefd0b458e91fb5");
                request.AddField("oauth_token", (string)settings["twitter_token"]);
                request.AddField("oauth_secret", (string)settings["twitter_tokensecret"]);
                request.AddField("message", "");
                 client.BeginRequest(request, new RestCallback(Callback));

             }
        }
开发者ID:vapps,项目名称:HDStream,代码行数:25,代码来源:TwitterWrite.xaml.cs

示例5: ShareOnTwitter

        //void fb_PostCompleted(object sender, FacebookApiEventArgs e)
        //{

        //    if (e.Error != null)
        //    {
        //        Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
        //        return;
        //    }
        //    else
        //    {
        //        Dispatcher.BeginInvoke(() =>
        //        {
        //            progbar1.IsIndeterminate = false;
        //            progbar1.Visibility = Visibility.Collapsed;
        //            MessageBox.Show("Successfully shared on Facebook");
        //            //if (NavigationService.CanGoBack)
        //            //    NavigationService.GoBack();

        //        });

        //    }
        //}


        public  void ShareOnTwitter()
        {
            OAuthCredentials credentials = new OAuthCredentials();

            credentials.Type = OAuthType.ProtectedResource;
            credentials.SignatureMethod = OAuthSignatureMethod.HmacSha1;
            credentials.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader;
            credentials.ConsumerKey = TwitterSettings.ConsumerKey;
            credentials.ConsumerSecret = TwitterSettings.ConsumerKeySecret;

            credentials.Token = tokenx;
            credentials.TokenSecret = tokensecx;
            credentials.Version = "1.0";
            //credentials.ClientUsername = "";
            //credentials.CallbackUrl = "www.google.com";

            //var service = new TwitterService(TwitterSettings.ConsumerKey, TwitterSettings.ConsumerKeySecret);

            //service.AuthenticateWith(tokenx, tokensecx);

            //var resized = img.Resize(img.PixelWidth / 4, img.PixelHeight / 4, WriteableBitmapExtensions.Interpolation.Bilinear);

            //var fileStream = new MemoryStream();
            //resized.SaveJpeg(fileStream, resized.PixelWidth, resized.PixelHeight, 100, 100);
            //fileStream.Seek(0, SeekOrigin.Begin);

            //SendTweetWithMediaOptions msgMedia = new SendTweetWithMediaOptions();
            //msgMedia.Status = photo_text.Text;
            //Dictionary<string, Stream> imageDict = new Dictionary<string, Stream> { { fileName, fileStream } };
            ////imageDict.Add(imagePath, imageStream);
            //msgMedia.Images = imageDict;
            ////status = service.SendTweetWithMedia(new SendTweetWithMediaOptions() { Status = readerMsg.Message, Images = imageDict });
            //service.SendTweetWithMedia(msgMedia, tweetResponse);


            //other method

            RestClient _client = new RestClient
            {
                Authority = "https://api.twitter.com",
                HasElevatedPermissions = true,

            };

            var twitterRequest = new RestRequest
            {
                Credentials = credentials,
                Path = "/1.1/statuses/update_with_media.json",
                Method = WebMethod.Post
            };

            //twitterRequest.AddHeader("content-type", "application/x-www-form-urlencoded");

            //twitterRequest.AddHeader("content-type", "multipart/form-data");


            //twitterRequest.AddField("consumer_token", TwitterSettings.ConsumerKey);
            //twitterRequest.AddField("consumer_secret", TwitterSettings.ConsumerKeySecret);
            //twitterRequest.AddField("oauth_token", tokenx);
            //twitterRequest.AddField("oauth_secret", tokensecx);



            var resized = img.Resize(img.PixelWidth / 4, img.PixelHeight / 4, WriteableBitmapExtensions.Interpolation.Bilinear);

            var fileStream = new MemoryStream();
            resized.SaveJpeg(fileStream, resized.PixelWidth, resized.PixelHeight, 100, 100);
            fileStream.Seek(0, SeekOrigin.Begin);


            //twitterRequest.AddParameter("status", photo_text.Text);
            twitterRequest.AddField("status", photo_text.Text); 
            twitterRequest.AddFile("media[]", "test", fileStream, "image/jpeg");


            _client.BeginRequest(twitterRequest, NewTweetCompleted);
//.........这里部分代码省略.........
开发者ID:NSemaX,项目名称:ShareToAll_WindowsPhone,代码行数:101,代码来源:PostAPhoto.xaml.cs

示例6: photoChooserTask_Completed

        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                img_bool = true;

                using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (myIsolatedStorage.FileExists("img.jpg"))
                    {
                        myIsolatedStorage.DeleteFile("img.jpg");
                    }
                    IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile("img.jpg");
                    Uri uri = new Uri("img.jpg", UriKind.Relative);
                    BitmapImage bitmap = new BitmapImage();
                    bitmap.SetSource(e.ChosenPhoto);
                    WriteableBitmap wb = new WriteableBitmap(bitmap);
                    System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                    wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                    fileStream.Close();

                    photo.Content = "Remove a picture";
                    if (twitter_chk.IsChecked == true)
                    {
                        share_pg.Visibility = Visibility.Visible;
                        share.Visibility = Visibility.Collapsed;
                        var client = new RestClient
                        {
                            Authority = "http://api.twipl.net/",
                            VersionPath = "1",
                        };

                        var request = new RestRequest
                        {
                            Path = "upload.json" // can be upload.xml or whatever, but you have to parse it accordingly
                        };

                        IsolatedStorageFileStream fileStream2 = myIsolatedStorage.OpenFile("img.jpg", FileMode.Open, FileAccess.Read);
                        request.AddFile("media1", "img.jpg", fileStream2);
                        request.AddField("key", "b76ecda29f7c47e0bfefd0b458e91fb5");
                        request.AddField("oauth_token", (string)settings["twitter_token"]);
                        request.AddField("oauth_secret", (string)settings["twitter_tokensecret"]);
                        request.AddField("message", "");
                        client.BeginRequest(request, new RestCallback(Callback));
                    }
                }
            }
        }
开发者ID:vapps,项目名称:HDStream,代码行数:48,代码来源:MainMenu.xaml.cs

示例7: ApplicationBarIconButton_Click_1

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

            RestRequest request2 = new RestRequest
            {
                Path = id + "/likes",
            };

            request2.AddField("access_token", (string)settings["facebook_token"]);
            var callback = new RestCallback(
                (restRequest, restResponse, userState) =>
                {
                    Dispatcher.BeginInvoke(delegate()
                    {
                        if (like_cnt > 0)
                            hour.Text += " 하고 나도 좋아요";
                        else
                            hour.Text += "내가 좋아한 글";
                    });
                }
                );
            client2.BeginRequest(request2, callback);
        }
开发者ID:vapps,项目名称:HDStream,代码行数:27,代码来源:FacebookPostView.xaml.cs

示例8: CallDailyBurnApiPost

        public static void CallDailyBurnApiPost(string apiExtensionPath, RestCallback callback, Dictionary<string, string> parameters)
        {
            string accessToken = HelperMethods.GetKeyValue("accessToken");
            string accessTokenSecret = HelperMethods.GetKeyValue("accessTokenSecret");
            var credentials = new OAuthCredentials
            {
                Type = OAuthType.ProtectedResource,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.UrlOrPostParameters,
                ConsumerKey = DailyBurnSettings.consumerKey,
                ConsumerSecret = DailyBurnSettings.consumerKeySecret,
                Token = accessToken,
                TokenSecret = accessTokenSecret,
                Version = "1.0"
            };


            var restClient = new RestClient
            {
                Authority = DailyBurnSettings.AuthorityUri,
                HasElevatedPermissions = true,
                Credentials = credentials,
                Method = WebMethod.Post
            };

            var restRequest = new RestRequest
            {
                Path = apiExtensionPath,
                Method = WebMethod.Post
            };

            if (parameters != null)
            {
                foreach (KeyValuePair<string, string> param in parameters)
                {
                    restRequest.AddField(param.Key, param.Value);

                }
            }

            restClient.BeginRequest(restRequest, new RestCallback(callback));
        }
开发者ID:mmydland,项目名称:burntracker,代码行数:42,代码来源:HelperMethods.cs


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