private void Button_Click_1(object sender, RoutedEventArgs e) { if (answer == userAns) { ToastPhoto.Source = new BitmapImage(new Uri("images/correct.png", UriKind.Relative)); ToastPhoto.Visibility = Visibility.Visible; Story.Begin(); } else { ToastPhoto.Source = new BitmapImage(new Uri("images/incorrect.png", UriKind.Relative)); ToastPhoto.Visibility = Visibility.Visible; Story.Begin(); } postAnswer.Add("uid", userAns); postAnswer.Add("publish", App.Check); PostClient pc = new PostClient(postAnswer); pc.DownloadStringCompleted += pc_DownloadStringCompleted; pc.DownloadStringAsync(new Uri("http://facebookfriendsquiz.appspot.com/choose", UriKind.Absolute)); VarOneFrame.Source = new BitmapImage(new Uri("images/photo.png", UriKind.Relative)); VarTwoFrame.Source = new BitmapImage(new Uri("images/photo.png", UriKind.Relative)); VarThreeFrame.Source = new BitmapImage(new Uri("images/photo.png", UriKind.Relative)); nextButton.IsEnabled = false; postAnswer.Clear(); getQuestions(); }
public void login_message() { this.progressBar1.IsIndeterminate = true; this.progressBar1.Visibility = System.Windows.Visibility.Visible; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("username", "8785169"); parameters.Add("password", password.Text); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { JObject userobj = JObject.Parse(e.Result); if (userobj["info"].ToString() == "success") { //NavigationService.Navigate(new Uri("/mail.xaml", UriKind.Relative)); this.progressBar1.IsIndeterminate = false; this.progressBar1.Visibility = System.Windows.Visibility.Collapsed; NavigationService.GoBack(); } } }; proxy.DownloadStringAsync(new Uri("http://cxds.sysu.me/user/login", UriKind.Absolute)); }
/// <summary> /// Request a new device key registered to a specific API key. /// </summary> /// <param name="apiKey">The API key.</param> /// <returns> /// <c>true</c>: When request suceeded /// <c>false</c>: When request failed /// </returns> public void RequestDevKey() { string uriPath = settings.mainServer + "/api/service/request-device-key"; string responseResult = null; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("api_key", this.apiKey); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { //save the response/result responseResult = e.Result; if (responseResult != null) { //store the device key settings.DeviceKey = responseResult; DeviceKeyStatus(this, new GeopAppApiEventArgs("Device Key reccieved")); } else { DeviceKeyStatus(this, new GeopAppApiEventArgs(new Exception("Error retrieving device key"))); } } else { DeviceKeyStatus(this, new GeopAppApiEventArgs(new Exception("Error retrieving device key"))); } }; proxy.DownloadStringAsync(new Uri(uriPath, UriKind.Absolute)); }
public void get_chengjiu_list() { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("username", "8785169"); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { JObject userobj = JObject.Parse(e.Result); JArray userdata_info = (JArray)userobj["detail"]; my_chengjiu_detile a = new my_chengjiu_detile() { achiname = userdata_info[0]["achiname"].Value <string>(), amount = userdata_info[0]["amount"].Value <string>(), outline = "折翼天使" }; detail.Add(a); listbox_chengjiu.ItemsSource = detail; } }; proxy.DownloadStringAsync(new Uri("http://cxds.sysu.me/user/achievement", UriKind.Absolute)); }
// 心路历程信息获取 public void get_message() { List <user> xinlu_list = new List <user>(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("username", "8785169"); parameters.Add("date", "2011/12/16"); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { JObject userobj = JObject.Parse(e.Result); int i = 2; JObject userdata_info = (JObject)userobj["detail"]; JArray mess2011 = (JArray)userdata_info["1"]; JArray mess2012 = (JArray)userdata_info["2"]; int p = 0; foreach (var obj in mess2011) { i = (i + 2) % 4; user a = new user() { pid = obj["id"].Value <string>(), content = obj["content"].Value <string>(), posttime = obj["posttime"].Value <string>(), source = "", source2 = "", title = obj["title"].Value <string>(), color1 = col[i], color2 = col[i + 1] }; if (mess2012.Count == 0 || p > mess2012.Count - 1) { a.pid2 = ""; a.posttime2 = obj["posttime"].Value <string>(); a.content2 = "今天没有消息"; } else { a.pid2 = mess2012[p]["id"].Value <string>(); a.posttime2 = mess2012[p]["posttime"].Value <string>(); a.content2 = mess2012[p]["content"].Value <string>(); } p++; xinlu_list.Add(a); } listBox_xinlu.ItemsSource = xinlu_list; } }; proxy.DownloadStringAsync(new Uri("http://cxds.sysu.me/post/get", UriKind.Absolute)); }
void weibolongin(string user, string password) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("username", "8785169"); parameters.Add("password", "8785169"); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { if (e.Result == "") { MessageBox.Show("亲,你的网络可能有问题了。"); this.progressBar1.IsIndeterminate = false; } else { try { JObject userobj = JObject.Parse(e.Result); if (userobj["info"].ToString() == "success") { this.progressBar1.IsIndeterminate = false; this.progressBar1.Visibility = System.Windows.Visibility.Collapsed; //if (((JObject)((JObject)userobj["detail"])["detail"]).ToString() == "[]") //{ NavigationService.Navigate(new Uri("/daohang/weiboshouquan.xaml", UriKind.Relative)); //} //else //{ // NavigationService.Navigate(new Uri("/main.xaml", UriKind.Relative)); //} } else { this.progressBar1.IsIndeterminate = false; this.progressBar1.Visibility = System.Windows.Visibility.Collapsed; MessageBox.Show("用户名或密码错误"); } } catch { MessageBox.Show("亲,你的网络可能有问题了。"); this.progressBar1.IsIndeterminate = false; this.progressBar1.Visibility = System.Windows.Visibility.Collapsed; } } } }; proxy.DownloadStringAsync(new Uri("http://cxds.sysu.me/user/login", UriKind.Absolute)); }
/// <summary> /// Adds a location region with an associated name. /// </summary> /// <param name="deviceId">A 32-character device API key assigned to the device when it was registered.</param> /// <param name="latitude">The latitude of the location region.</param> /// <param name="longitude">The longitude of the location region.</param> /// <param name="name">The given name to this region.</param> /// <param name="time">(OPTIONAL, NULLABLE)The time the update took place.</param> /// <param name="radius">(OPTIONAL, NULLABLE)The radius of the circular area which should be considered part of this region.</param> /// <returns> /// <c>true</c>: When request suceeded /// <c>false</c>: When request failed /// </returns> public void AddRegion(string latitude, string longitude, string name, string time, string radius) { string uriPath = settings.mainServer + "/api/device/add-region"; string responseResult = null; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("device_id", this.deviceId); parameters.Add("latitude", latitude); parameters.Add("longitude", longitude); parameters.Add("name", name); //Check for optinal values (NULLABLE) if (time != null) { parameters.Add("time", time); } if (radius != null) { parameters.Add("radius", radius); } PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { //Process the result responseResult = e.Result; if (responseResult.Contains("OK")) { AddRegionStatus(this, new GeopAppApiEventArgs("Added Region")); } else { AddRegionStatus(this, new GeopAppApiEventArgs(new Exception("Failed to add region"))); } } else { AddRegionStatus(this, new GeopAppApiEventArgs(new Exception("Failed to add region"))); } }; proxy.DownloadStringAsync(new Uri(uriPath, UriKind.Absolute)); }
/// <summary> /// Registers the specified device. /// </summary> /// <param name="deviceKey">The device key.</param> /// <param name="deviceName">Name of the device.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> public void RegisterDevice(string deviceName, string username, string password) { string uriPath = settings.mainServer + "/api/device/register"; string responseResult = null; Dictionary <string, object> parameters = new Dictionary <string, object>(); if (this.deviceKey != null) { parameters.Add("device_key", this.deviceKey); } else { return; } parameters.Add("device_name", deviceName); parameters.Add("username", username); parameters.Add("password", password); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { //save the response/result responseResult = e.Result; if (responseResult != null) { settings.DeviceId = responseResult; RegisterStatus(this, new GeopAppApiEventArgs("Successfully Registered")); } else { RegisterStatus(this, new GeopAppApiEventArgs(new Exception("Failed to register"))); } } else { RegisterStatus(this, new GeopAppApiEventArgs(new Exception("Failed to register"))); } }; proxy.DownloadStringAsync(new Uri(uriPath, UriKind.Absolute)); }
public void SendRequest() { PostClient proxy = new PostClient(this.PrepareParams()); proxy.Method = this.Method; proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { string data = e.Result; this.OnRequestComplete.Invoke(this, data); } else { this.OnRequestComplete.Invoke(this, null); } }; proxy.DownloadStringAsync(new Uri(this.GetServerName(), UriKind.Absolute)); }
public static PostClient SendPostClient(string urlPrefix, Dictionary<string, object> parameters) { /* * WP7 会缓存相同url 的返回结果 所以这里需要添加 guid 参数 */ if ( parameters != null && parameters.ContainsKey("guid") == false) { parameters. Add( "guid", Guid. NewGuid( ). ToString( ) ); } PostClient client = new PostClient( parameters ) { UserAgent = Config. UserAgent, }; //抓取到 Cookie client. OnGetCookie += (cookie) => { Config. Cookie = cookie; }; client. DownloadStringAsync( new Uri( urlPrefix, UriKind. Absolute ), Config. Cookie.EnsureNotNull() ); return client; }
/// <summary> /// Checkins the specified latitude. /// </summary> /// <param name="latitude">The latitude.</param> /// <param name="longitude">The longitude.</param> /// <param name="time">The time.</param> /// <param name="devId">The dev id.</param> /// <returns> /// <c>true</c>: When request suceeded /// <c>false</c>: When request failed /// </returns> public void CheckIn(string latitude, string longitude, string time) { string responseResult = null; string uriPath = settings.mainServer + "/api/device/check-in"; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("device_id", this.deviceId); parameters.Add("latitude", latitude); parameters.Add("longitude", longitude); parameters.Add("time", time); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { //Process the result responseResult = e.Result; if (responseResult.Contains("OK")) { CheckInStatus(this, new GeopAppApiEventArgs("Sucessfully Checked In")); } else { CheckInStatus(this, new GeopAppApiEventArgs(new Exception("Failed to Check-in"))); } } else { CheckInStatus(this, new GeopAppApiEventArgs(new Exception("Failed to Check-in"))); } }; proxy.DownloadStringAsync(new Uri(uriPath, UriKind.Absolute)); }
void weibolongin(string user, string password) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("username", "8785169"); parameters.Add("type", "weibo"); parameters.Add("token", App.AccessToken); PostClient proxy = new PostClient(parameters); proxy.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { if (e.Result == "") { MessageBox.Show("亲,你的网络可能有问题了。"); } else { try { JObject userobj = JObject.Parse(e.Result); if (userobj["info"].ToString() == "success") { MessageBox.Show("微博授权成功,可以进入应用了,也可以进行人人授权"); } } catch { MessageBox.Show("亲,你的网络可能有问题了。"); } } } }; proxy.DownloadStringAsync(new Uri("http://cxds.sysu.me/user/impower", UriKind.Absolute)); }