示例#1
0
        private List <User> getAssigneesProj()
        {
            List <User> userlist = new List <User>();

            var maxresults = 1000;

            for (var i = 0; i < 100; i++)
            {
                var apicall = "user/assignable/search?project=" +
                              ((Project)projCombo.SelectedItem).key + "&maxResults=" + maxresults + "&startAt=" + (i * maxresults);
                var request = new RestRequest(apicall, Method.GET);
                request.AddHeader("Content-Type", "application/json");
                request.RequestFormat           = Arup.RestSharp.DataFormat.Json;
                request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
                var response = JiraClient.Client.Execute <List <User> >(request);
                if (!RestCallback.Check(response) || !response.Data.Any())
                {
                    break;
                }

                userlist.AddRange(response.Data);
                if (response.Data.Count < maxresults)
                {
                    break;
                }
            }
            return(userlist);
        }
示例#2
0
        static public void PostTweet(string message, RestCallback callback)
        {
            var credentials = new OAuthCredentials
            {
                Type              = OAuthType.ProtectedResource,
                SignatureMethod   = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                ConsumerKey       = AppObject.GameInfo.TwitterConsumerKey,
                ConsumerSecret    = AppObject.GameInfo.TwitterConsumerSecret,
                Token             = TwitterClient.AccessToken,
                TokenSecret       = TwitterClient.AccessTokenSecret,
                Version           = "1.0"
            };

            var restClient = new RestClient
            {
                Authority = "https://api.twitter.com",
                HasElevatedPermissions = true
            };

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

            restRequest.AddParameter("status", message);
            restClient.BeginRequest(restRequest, callback);
        }
示例#3
0
        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();
        }
示例#4
0
        static public void getFollower(RestCallback callback)
        {
            var credentials = new OAuthCredentials
            {
                Type              = OAuthType.ProtectedResource,
                SignatureMethod   = OAuthSignatureMethod.HmacSha1,
                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                ConsumerKey       = AppObject.GameInfo.TwitterConsumerKey,
                ConsumerSecret    = AppObject.GameInfo.TwitterConsumerSecret,
                Token             = TwitterClient.AccessToken,
                TokenSecret       = TwitterClient.AccessTokenSecret,
                Version           = "1.0"
            };

            var restClient = new RestClient
            {
                Authority = "https://api.twitter.com",
                HasElevatedPermissions = true
            };

            var restRequest = new RestRequest
            {
                Credentials = credentials,
                Path        = "/1.1/followers/ids.json?cursor=-1&user_id=" + TwitterClient.UserID,
                Method      = WebMethod.Get
            };

            restClient.BeginRequest(restRequest, callback);
        }
示例#5
0
        public static void CallDailyBurnApiDelete(string apiExtensionPath, RestCallback callback)
        {
            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.Delete
            };

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

            restClient.BeginRequest(restRequest, new RestCallback(callback));
        }
示例#6
0
        private List <Classes.Component> getComponents()
        {
            List <Classes.Component> components = new List <Component>();

            try
            {
                var request = new RestRequest("project/" + ((Project)projCombo.SelectedItem).key + "/components", Method.GET);
                request.AddHeader("Content-Type", "application/json");
                request.RequestFormat           = Arup.RestSharp.DataFormat.Json;
                request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

                var response = JiraClient.Client.Execute <List <Classes.Component> >(request);
                if (!RestCallback.Check(response) || !response.Data.Any())
                {
                    return(components);
                }

                components.AddRange(response.Data);
            }
            catch (System.Exception ex1)
            {
                MessageBox.Show("exception: " + ex1);
            }

            return(components);
        }
        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);
        }
 private static IEnumerator callREST(string data, RestCallback cb)
 {
     WWW www = new WWW(ADDRESS, StringToByteArray(data));
     yield return www;
     if(www.error == null) {
         cb(www.text, true);
     } else {
         cb(null, false);
     }
 }
示例#9
0
        private async Task Get(string url, RestCallback <string> callBack)
        {
            var handler = new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
                UseCookies             = true,
                UseDefaultCredentials  = false,
                AllowAutoRedirect      = false
            };

            try
            {
                WeYaLog.Instance.Info(this.ToString() + url);

                using (var client = new HttpClient(handler))
                {
                    var token = new CancellationToken();
                    token.ThrowIfCancellationRequested();
                    Debug.WriteLine(url);
                    var response = await client.GetAsync(url, token);

                    var json = await response.Content.ReadAsStringAsync();

                    callBack?.Invoke(new Callback <string>(json));
                }
            }
            catch (XmlException e)
            {
                Debug.WriteLine(e);
                callBack?.Invoke(new Callback <string>(HttpErrorStatus.JsonError, e));
            }
            catch (OperationCanceledException e)
            {
                Debug.WriteLine(e);
                callBack?.Invoke(new Callback <string>(HttpErrorStatus.UserCancelOperation, e));
            }
            catch (HttpRequestException e)
            {
                Debug.WriteLine(e);
                callBack?.Invoke(new Callback <string>(HttpErrorStatus.NetworkError, e));
            }
            catch (WebException e)
            {
                Debug.WriteLine(e);
                callBack?.Invoke(new Callback <string>(HttpErrorStatus.NetworkError, e));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                callBack?.Invoke(new Callback <string>(HttpErrorStatus.UnknownError, e));
            }
        }
示例#10
0
        protected async Task Get(ServiceArgument args, RestCallback <string> callBack)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var i in args.Dic)
            {
                sb.Append(i.Key);
                sb.Append("=");
                sb.Append(i.Value);
                sb.Append("&");
            }
            await Get(string.Concat(args.Uri, sb.ToString().TrimEnd('&')), callBack);
        }
示例#11
0
        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);
        }
示例#12
0
        public void Callback(RestCallback callback)
        {
            if (callback == null) {
                throw new ArgumentNullException("callback");
            }

            if (_completed) {
                callback();
            }

            if (_callbacks == null) {
                _callbacks = new List<RestCallback>();
            }
            _callbacks.Add(callback);
        }
        public static void AddNewLogEntry(SearchResultItem sri, string servings_eaten, string dateValue, KeyValuePair<int, string> meal, RestCallback callback)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("food_log_entry[food_id]", sri.FoodId.ToString());
            parameters.Add("food_log_entry[servings_eaten]", servings_eaten);
            parameters.Add("food_log_entry[logged_on]", dateValue);

            if (meal.Key != 0)  
                parameters.Add("food_log_entry[meal_name_id]", meal.Key.ToString());

            HelperMethods.CallDailyBurnApiPost(DailyBurnSettings.FoodLogEntriesAPI,
                                            callback,
                                            parameters);
            //we invalidated the model so cause a get
            DailyBurnService.NutritionLog = null;
        }
示例#14
0
        public void Callback(RestCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (_completed)
            {
                callback();
            }

            if (_callbacks == null)
            {
                _callbacks = new List <RestCallback>();
            }
            _callbacks.Add(callback);
        }
示例#15
0
        public static void CallDailyBurnApi(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.HttpAuthorizationHeader,
                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.Get
            };

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

            if (parameters != null)
            {
                foreach (KeyValuePair<string, string> param in parameters)
                {
                    restRequest.AddParameter(param.Key, param.Value);
                }
            }
            
            restClient.BeginRequest(restRequest, new RestCallback(callback));
        }
        public static void ModifyFoodEntry (food_log_entry ModifiedEntry, RestCallback Callback)
        {
            //Modify is not implemented so we will do a delete and an add
            //Store off the actual callback and IDfor later
            modifiedCallback = Callback;
            oldId = ModifiedEntry.id;

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("food_log_entry[food_id]", ModifiedEntry.food_id.ToString());
            parameters.Add("food_log_entry[servings_eaten]", ModifiedEntry.servings_eaten.ToString());
            parameters.Add("food_log_entry[logged_on]", ModifiedEntry.created_at.ToString("yyyy-MM-dd"));

            if (ModifiedEntry.meal_name_id != 0)
                parameters.Add("food_log_entry[meal_name_id]", ModifiedEntry.meal_name_id.ToString());

            HelperMethods.CallDailyBurnApiPost(DailyBurnSettings.FoodLogEntriesAPI,
                                          modifiedFoodLogAddCallback,
                                          parameters);
            //we invalidated the model so cause a get
            DailyBurnService.NutritionLog = null;

        }
示例#17
0
        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();
        }
 public void BeginRequest(string path, RestCallback callback, object userState)
 {
     BeginRequest(path, null, WebMethod.Post, callback, userState);
 }
示例#19
0
        public void BeginRequest(string path, IDictionary <string, string> parameters, IDictionary <string, File> files, WebMethod method, RestCallback callback, object userState)
        {
            var request = new RestRequest
            {
                Path   = path,
                Method = method
            };

            if (files != null)
            {
                foreach (var f in files)
                {
                    request.AddFile(f.Key, f.Value.FileName, f.Value.FilePath);
                }
            }

            if (Credentials != null)
            {
                request.Credentials = Credentials;
            }

            if (parameters != null)
            {
                foreach (var p in parameters)
                {
                    request.AddParameter(p.Key, p.Value);
                }
            }
#if !SILVERLIGHT
            if (files != null)
            {
                foreach (var f in files)
                {
                    byte[] rawData = System.IO.File.ReadAllBytes(f.Value.FilePath);
                    request.AddPostContent(rawData);
                }
            }
            //request.AddFile(f.Key, f.Value.FileName, f.Value.FilePath, "image/jpeg");
#endif

            Client.BeginRequest(request, (req, res, obj) =>
            {
                if (callback != null)
                {
                    callback(req, res, obj);
                }
            }, userState);
        }
示例#20
0
 public void BeginRequest(string path, IDictionary <string, string> parameters, WebMethod method, RestCallback callback, object userState)
 {
     BeginRequest(path, parameters, null, method, callback, userState);
 }
示例#21
0
 public void BeginRequest(string path, RestCallback callback, object userState)
 {
     BeginRequest(path, null, WebMethod.Post, callback, userState);
 }
示例#22
0
 public void BeginRequest(string path, RestCallback callback)
 {
     BeginRequest(path, null, WebMethod.Post, callback);
 }
 public void BeginRequest(string path, IDictionary<string, string> parameters, WebMethod method, RestCallback callback, object userState)
 {
     BeginRequest(path, parameters, null, method, callback, userState);
 }
        public void BeginRequest(string path, IDictionary<string, string> parameters, IDictionary<string, File> files, WebMethod method, RestCallback callback, object userState)
        {
            var request = new RestRequest
            {
                Path = path,
                Method = method
            };

            if (files != null)
            {
                foreach (var f in files)
                    request.AddFile(f.Key, f.Value.FileName, f.Value.FilePath);
            }

            if (Credentials != null)
                request.Credentials = Credentials;

            if (parameters != null)
                foreach (var p in parameters)
                {
                    request.AddParameter(p.Key, p.Value);
                }
#if !SILVERLIGHT

            if (files != null)
                foreach (var f in files)
                {
                    byte[] rawData = System.IO.File.ReadAllBytes(f.Value.FilePath);
                    request.AddPostContent(rawData);
                }
            //request.AddFile(f.Key, f.Value.FileName, f.Value.FilePath, "image/jpeg");
#endif

            Client.BeginRequest(request, (req, res, obj) =>
            {
                if (callback != null)
                    callback(req, res, obj);
            }, userState);
        }
示例#25
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            List <JiraAccount> accounts = jiraAccounts.ItemsSource as List <JiraAccount>;

            // ensure only one active account
            if (accounts.FindAll(ac => ac.active).Count != 1)
            {
                MessageBox.Show("You need to select only one active account!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            // check guid field id for active account
            JiraAccount activeAccount = accounts.Find(ac => ac.active);

            if (string.IsNullOrWhiteSpace(activeAccount.username))
            {
                // for setting BCF username only
                DialogResult = true;
                return;
            }
            var client = new RestClient(activeAccount.jiraserver);

            client.CookieContainer = new System.Net.CookieContainer();
            var request = new RestRequest("/rest/auth/1/session", Method.POST);

            request.AddHeader("content-type", "application/json");
            string requestBody = "{\"username\": \"" + activeAccount.username + "\",\"password\": \"" + activeAccount.password + "\"}";

            request.AddParameter("application/json", requestBody, ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var request2 = new RestRequest("/rest/api/2/field", Method.GET);
                IRestResponse <List <JiraCustomField> > response2 = null;
                try
                {
                    response2 = client.Execute <List <JiraCustomField> >(request2);
                    JiraCustomField guidField = response2.Data.Find(field => field.name == "GUID");
                    if (guidField != null)
                    {
                        activeAccount.guidfield = guidField.id;
                        MessageBox.Show(string.Format("The GUID field Id on {0} is {1}. Now you can create an issue with the plug-ins of Revit and Navisworks!", activeAccount.jiraserver, guidField.id), "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("There's no custom field named GUID on {0}. Creating an issue might fail. Please check with your Jira administrator!", activeAccount.jiraserver), "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                catch (Exception ex)
                {
                    RestCallback.LogRequest(client, request2, response2, ex);
                    MessageBox.Show(string.Format("Cannot connect to {0}. Please check with your Jira administrator!\nStatus Code: " + response2.StatusCode.ToString(), activeAccount.jiraserver), "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                RestCallback.LogRequest(client, request, response);
                MessageBox.Show("Login failed. Please check your username/password!\nStatus Code: " + response.StatusCode.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            DialogResult = true;
        }
示例#26
0
        private void share_Click(object sender, RoutedEventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("This application must require for internet connection. Please check your internet connection status", "Sorry", MessageBoxButton.OK);
                return;
            }
            if (twitter_chk.IsChecked == false && facebook_chk.IsChecked == false && me2day_chk.IsChecked == false)
            {
                MessageBox.Show("Any account hasn't availiable. Please setting your account.", "Sorry", MessageBoxButton.OK);
                return;
            }
            else
            {
                IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                if (WatermarkTB.Text.Length == 0 || WatermarkTB.Text == emptystr)
                {
                    MessageBox.Show("Please input your minds :)", "Sorry", MessageBoxButton.OK);
                    return;
                }
                share_status = true;
                wait_text.Text = "Share in progress.. Pleas wait";
                share_pg.Visibility = Visibility.Visible;
                tw_chk = false;
                mw_chk = false;
                fw_chk = false;
                share.Visibility = Visibility.Collapsed;

                if (me2day_chk.IsChecked == true)
                {
                    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);

                    if (img_bool)
                    {
                        IsolatedStorageFileStream fileStream2 = myIsolatedStorage.OpenFile("img.jpg", FileMode.Open, FileAccess.Read);
                        request.AddFile("attachment", "image.jpg", fileStream2, "image/jpeg");
                    }

                    var callback = new RestCallback(
                        (restRequest, restResponse, userState) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                mw_chk = true;
                                chk_share();
                            });
                        }
                    );

                    client.BeginRequest(request, callback);

                }

                if (twitter_chk.IsChecked == true)
                {
                    TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
                    service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
                    string tweet = WatermarkTB.Text;
                    if (img_bool == true)
                        tweet += " " + twit_pic;

                    service.SendTweet(tweet,
                        (tweets, response) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                tw_chk = true;
                                chk_share();
                            });
                        });

                }

                if (facebook_chk.IsChecked == true)
                {
                    RestClient client2 = new RestClient
                    {
                        Authority = "https://graph.facebook.com/",
                    };

                    RestRequest request2 = new RestRequest
                    {
                        Path = "/me/feed?message=" + WatermarkTB.Text
                    };
                    if (img_bool)
                    {
                        IsolatedStorageFileStream fileStream2 = myIsolatedStorage.OpenFile("img.jpg", FileMode.Open, FileAccess.Read);

                        request2 = new RestRequest
                        {
                            Path = "/photos?message=" + WatermarkTB.Text
                        };
                        request2.AddFile("photo", "image.jpg", fileStream2);
                    }
                    request2.AddField("access_token", (string)settings["facebook_token"]);
                    var callback = new RestCallback(
                        (restRequest, restResponse, userState) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                fw_chk = true;
                                chk_share();
                            });
                        }
                        );
                    client2.BeginRequest(request2, callback);
                }

            }
        }
示例#27
0
        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);
        }
示例#28
0
        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);
        }
 public void BeginRequest(string path, RestCallback callback)
 {
     BeginRequest(path, null, WebMethod.Post, callback);
 }
 public static void DeleteFoodLogEntry(int EntryId, RestCallback Callback)
 {
     HelperMethods.CallDailyBurnApiDelete(DailyBurnSettings.DeleteFoodLogEntriesAPI + "/" + EntryId.ToString(), Callback);
     DailyBurnService.NutritionLog = null;
 }