public VimeoChannel GetChannelInfo(string name) { HttpWebResponse response = SocialUtils.DoHttpGetRequest("http://vimeo.com/api/v2/channel/" + name + "/info.xml"); if (response.StatusCode == HttpStatusCode.OK) { return(VimeoChannel.ParseMultiple(XElement.Parse(response.GetAsString())).FirstOrDefault()); } throw new VimeoException(response.GetAsString()); }
public VimeoChannelsResponse GetUserChannels(string name) { HttpWebResponse response = SocialUtils.DoHttpGetRequest("http://vimeo.com/api/v2/" + name + "/channels.xml"); if (response.StatusCode == HttpStatusCode.OK) { return(VimeoChannelsResponse.Parse(XElement.Parse(response.GetAsString()))); } throw new VimeoException(response.GetAsString()); }
/// <summary> /// Get a list of channel videos. /// </summary> /// <param name="id">The ID of the channel.</param> /// <param name="page">The Simple API only allows to browse pages 1 through 3.</param> public VimeoChannelVideosResponse GetChannelVideos(string id, int page) { NameValueCollection query = new NameValueCollection(); if (page > 0) { query.Set("page", page + ""); } HttpWebResponse response = SocialUtils.DoHttpGetRequest("http://vimeo.com/api/v2/channel/" + id + "/videos.json", query); if (response.StatusCode == HttpStatusCode.OK) { return(VimeoChannelVideosResponse.Parse(JsonConverter.ParseArray(response.GetAsString()))); } string str = response.GetAsString(); Match match = Regex.Match(str, "<section id=\"exception_msg\" class=\"block\">(.+?)</section>", RegexOptions.Singleline); throw new VimeoException(match.Success ? match.Groups[1].Value.Trim() : str); }
public string Send(string token, string user, string device = null) { // Add mandatory parameters NameValueCollection data = new NameValueCollection { { "token", token }, { "user", user }, { "message", Message ?? "" } }; // Add optional parameters if (!String.IsNullOrEmpty(device)) { data.Add("device", device); } if (!String.IsNullOrEmpty(Url)) { data.Add("url", Url); } if (!String.IsNullOrEmpty(UrlTitle)) { data.Add("url_title", UrlTitle); } if (!String.IsNullOrEmpty(UrlTitle)) { data.Add("device", UrlTitle); } if (Priority != PushoverPriority.Normal) { data.Add("priority", (int)Priority + ""); } if (Sound != PushoverSound.Default) { data.Add("sound", Sound.ToString().ToLower()); } // Make the call HttpWebResponse response = SocialUtils.DoHttpPostRequest("https://api.pushover.net/1/messages.json", null, data); // Get as JSON object JsonObject json = (JsonObject)response.GetAsJson(); // Return the response body if successful if (response.StatusCode == HttpStatusCode.OK && json.GetInt32("status") == 1) { return(response.GetAsString()); } // Throw an exception with the given errors throw new PushoverException(response.StatusCode, json.GetArray("errors").Cast <string>()); }