/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> public IHttpPostData GetPostData() { SocialHttpPostData postData = new SocialHttpPostData(); if (IsDefault) { postData.Add("is_default", "true"); } if (!String.IsNullOrWhiteSpace(Location)) { postData.Add("location", Location); } if (!String.IsNullOrWhiteSpace(Message)) { postData.Add("message", Message); } if (!String.IsNullOrWhiteSpace(Name)) { postData.Add("name", Name); } if (!String.IsNullOrWhiteSpace(Place)) { postData.Add("place", Place); } if (Privacy != null && Privacy.Value != FacebookPrivacy.Default) { postData.Add("privacy", Privacy.ToString()); } return(postData); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> /// <returns>An instance of <see cref="IHttpPostData"/>.</returns> public IHttpPostData GetPostData() { if (ListId == 0) { throw new PropertyNotSetException(nameof(ListId)); } if (UserId == 0 && String.IsNullOrWhiteSpace(ScreenName)) { throw new PropertyNotSetException(nameof(UserId)); } SocialHttpPostData data = new SocialHttpPostData { { "list_id", ListId } }; if (UserId > 0) { data.Add("user_id", UserId); } if (!String.IsNullOrWhiteSpace(ScreenName)) { data.Add("screen_name", ScreenName); } return(data); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> public IHttpPostData GetPostData() { SocialHttpPostData postData = new SocialHttpPostData { IsMultipart = !String.IsNullOrWhiteSpace(Source) }; if (!String.IsNullOrWhiteSpace(Source)) { postData.AddFile("source", Source); } if (!String.IsNullOrWhiteSpace(Url)) { postData.Add("url", Url); } if (!String.IsNullOrWhiteSpace(Message)) { postData.Add("message", Message); } if (!String.IsNullOrWhiteSpace(Place)) { postData.Add("place", Place); } if (NoStory) { postData.Add("no_story", "true"); } return(postData); }
/// <summary> /// Makes a call to the Instagram API to exchange the specified <paramref name="authCode"/> for an access token. /// </summary> /// <param name="authCode">The authorization code obtained from an OAuth 2.0 login flow.</param> /// <returns>An instance of <see cref="InstagramTokenResponse"/> representing the response from the server.</returns> public virtual InstagramTokenResponse GetAccessTokenFromAuthCode(string authCode) { // Some validation if (String.IsNullOrWhiteSpace(ClientId)) { throw new PropertyNotSetException("ClientId"); } if (String.IsNullOrWhiteSpace(ClientSecret)) { throw new PropertyNotSetException("ClientSecret"); } if (String.IsNullOrWhiteSpace(RedirectUri)) { throw new PropertyNotSetException("RedirectUri"); } if (String.IsNullOrWhiteSpace(authCode)) { throw new ArgumentNullException("authCode"); } // Initialize collection with POST data IHttpPostData parameters = new SocialHttpPostData(); parameters.Add("client_id", ClientId); parameters.Add("client_secret", ClientSecret); parameters.Add("grant_type", "authorization_code"); parameters.Add("redirect_uri", RedirectUri); parameters.Add("code", authCode); // Make the call to the API SocialHttpResponse response = SocialUtils.Http.DoHttpPostRequest("https://api.instagram.com/oauth/access_token", null, parameters); // Parse the response return(InstagramTokenResponse.ParseResponse(response)); }
public IHttpPostData GetPostData() { SocialHttpPostData data = new SocialHttpPostData(); data.Add("status", Status ?? ""); if (ReplyTo != null) { data.Add("in_reply_to_status_id", ReplyTo); } if (PossiblySensitive) { data.Add("possibly_sensitive", "true"); } if (Latitude != null) { data.Add("lat", Latitude); } if (Longitude != null) { data.Add("long", Longitude); } if (PlaceId != null) { data.Add("place_id", PlaceId); } if (DisplayCoordinates) { data.Add("display_coordinates", "true"); } return(data); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "steamid", SteamId }, { "ticket", Ticket } }; return(data); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "requesthandle", RequestHandle } }; return(data); }
/// <summary> /// Writes the value to the specified <code>stream</code>. /// </summary> /// <param name="stream">The stream the value should be written to.</param> /// <param name="boundary">The multipart boundary.</param> /// <param name="newLine">The characters used to indicate a new line.</param> /// <param name="isLast">Whether the value is the last in the request body.</param> public void WriteToMultipartStream(Stream stream, string boundary, string newLine, bool isLast) { SocialHttpPostData.Write(stream, "--" + boundary + newLine); SocialHttpPostData.Write(stream, "Content-Disposition: form-data; name=\"" + Name + "\"" + newLine); SocialHttpPostData.Write(stream, newLine); SocialHttpPostData.Write(stream, Value); SocialHttpPostData.Write(stream, newLine); SocialHttpPostData.Write(stream, "--" + boundary + (isLast ? "--" : "") + newLine); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "steamid", SteamId }, { "sessionkey", SessionKey }, { "encrypted_loginkey", EncryptedLoginKey } }; return(data); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "sessionid", SessionId }, { "appid", AppId } }; if (SteamId != null) { data.Add("steamid", SteamId); } return(data); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "appid", AppId }, { "context", Context } }; if (SteamId != null) { data.Add("steamid", SteamId); } return(data); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "loginuser_list", LoginUserList }, { "install_config", InstallConfig }, { "shasentryfile", ShaSentryFile }, { "machineid", MachineId } }; return(data); }
/// <summary> /// Writes the value to the specified <code>stream</code>. /// </summary> /// <param name="stream">The stream the value should be written to.</param> /// <param name="boundary">The multipart boundary.</param> /// <param name="newLine">The characters used to indicate a new line.</param> /// <param name="isLast">Whether the value is the last in the request body.</param> public void WriteToMultipartStream(Stream stream, string boundary, string newLine, bool isLast) { SocialHttpPostData.Write(stream, "--" + boundary + newLine); SocialHttpPostData.Write(stream, "Content-Disposition: form-data; name=\"" + Name + "\"; filename=\"" + FileName + "\"" + newLine); SocialHttpPostData.Write(stream, "Content-Type: " + ContentType + newLine); SocialHttpPostData.Write(stream, newLine); stream.Write(Data, 0, Data.Length); SocialHttpPostData.Write(stream, newLine); SocialHttpPostData.Write(stream, newLine); SocialHttpPostData.Write(stream, "--" + boundary + (isLast ? "--" : "") + newLine); }
/// <summary> /// Exchanges the specified <paramref name="authCode"/> for a refresh token and an access token. /// </summary> /// <param name="authCode">The authorization code received from the Pinterest OAuth dialog.</param> /// <returns>An access token based on the specified <paramref name="authCode"/>.</returns> public PinterestTokenResponse GetAccessTokenFromAuthCode(string authCode) { // Initialize the POST data SocialHttpPostData data = new SocialHttpPostData { { "client_id", ClientId }, { "client_secret", ClientSecret }, { "code", authCode }, { "grant_type", "authorization_code" } }; // Make the call to the API SocialHttpResponse response = SocialUtils.Http.DoHttpPostRequest("https://api.pinterest.com/v1/oauth/token", null, data); // Parse the response return(PinterestTokenResponse.ParseResponse(response)); }
/// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns> protected virtual SocialHttpResponse GetAccessTokenResponse(string verifier) { // Some error checking if (String.IsNullOrWhiteSpace(AccessTokenUrl)) { throw new PropertyNotSetException(nameof(AccessTokenUrl)); } // Initialize the POST data IHttpPostData postData = new SocialHttpPostData(); postData.Add("oauth_verifier", verifier); // Make the call to the API/provider return(DoHttpPostRequest(AccessTokenUrl, null, postData)); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> public IHttpPostData GetPostData() { SocialHttpPostData data = new SocialHttpPostData(); if (Monitors != null && Monitors.Length > 0) { data.Add("monitors", String.Join("-", Monitors)); } if (Types != null && Types.Length > 0) { data.Add("types", String.Join("-", Types.Select(x => (int)x))); } if (Statuses != null && Statuses.Length > 0) { data.Add("statuses", String.Join("-", Statuses.Select(x => (int)x))); } if (CustomUptimeRatios != null && CustomUptimeRatios.Length > 0) { data.Add("custom_uptime_ratios", String.Join("-", CustomUptimeRatios)); } if (AllTimeUptimeRatio) { data.Add("all_time_uptime_ratio", "1"); } if (AllTimeUptimeDurations) { data.Add("all_time_uptime_durations", "1"); } if (Logs) { data.Add("logs", "1"); } if (Ssl) { data.Add("ssl", "1"); } if (Offset > 0) { data.Add("offset", Offset); } if (Limit > 0) { data.Add("limit", Limit); } return(data); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> /// <returns>An instance of <see cref="IHttpPostData"/>.</returns> public IHttpPostData GetPostData() { if (String.IsNullOrWhiteSpace(Name)) { throw new ArgumentNullException(nameof(Name)); } SocialHttpPostData data = new SocialHttpPostData(); data.Set("name", Name); data.Set("mode", StringUtils.ToCamelCase(Mode)); if (!String.IsNullOrWhiteSpace(Description)) { data.Add("description", Description); } return(data); }
/// <summary> /// Exchanges the specified <paramref name="authorizationCode"/> for a refresh token and an access token. /// </summary> /// <param name="authorizationCode">The authorization code received from the Sonos OAuth dialog.</param> /// <returns>An instance of <see cref="SonosTokenResponse"/> representing the response.</returns> /// <see> /// <cref>https://developer.sonos.com/reference/authorization-api/create-token/</cref> /// </see> public SonosTokenResponse GetAccessTokenFromAuthorizationCode(string authorizationCode) { // Input validation if (String.IsNullOrWhiteSpace(authorizationCode)) { throw new ArgumentNullException(nameof(authorizationCode)); } if (String.IsNullOrWhiteSpace(ClientId)) { throw new PropertyNotSetException(nameof(ClientId)); } if (String.IsNullOrWhiteSpace(ClientSecret)) { throw new PropertyNotSetException(nameof(ClientSecret)); } if (String.IsNullOrWhiteSpace(RedirectUri)) { throw new PropertyNotSetException(nameof(RedirectUri)); } // Initialize the POST data SocialHttpPostData postData = new SocialHttpPostData { { "grant_type", "authorization_code" }, { "code", authorizationCode }, { "redirect_uri", RedirectUri } }; // Initialize the request SocialHttpRequest request = new SocialHttpRequest { Method = SocialHttpMethod.Post, Url = "https://api.sonos.com/login/v3/oauth/access", PostData = postData }; // Update the "Authorization" header request.Authorization = "Basic " + SecurityUtils.Base64Encode(ClientId + ":" + ClientSecret); // Make a request to the server SocialHttpResponse response = request.GetResponse(); // Parse the JSON response return(SonosTokenResponse.ParseResponse(response)); }
/// <summary> /// Exchanges the specified <paramref name="authorizationCode"/> for a refresh token and an access token. /// </summary> /// <param name="authorizationCode">The authorization code received from the Spotify OAuth dialog.</param> /// <returns>An instance of <see cref="SpotifyTokenResponse"/> representing the response.</returns> /// <see> /// <cref>https://developer.spotify.com/web-api/authorization-guide/</cref> /// </see> public SpotifyTokenResponse GetAccessTokenFromAuthorizationCode(string authorizationCode) { // Input validation if (String.IsNullOrWhiteSpace(authorizationCode)) { throw new ArgumentNullException(nameof(authorizationCode)); } if (String.IsNullOrWhiteSpace(ClientId)) { throw new PropertyNotSetException(nameof(ClientId)); } if (String.IsNullOrWhiteSpace(ClientSecret)) { throw new PropertyNotSetException(nameof(ClientSecret)); } if (String.IsNullOrWhiteSpace(RedirectUri)) { throw new PropertyNotSetException(nameof(RedirectUri)); } // Initialize the POST data IHttpPostData postData = new SocialHttpPostData(); postData.Add("grant_type", "authorization_code"); postData.Add("code", authorizationCode); postData.Add("redirect_uri", RedirectUri); postData.Add("client_id", ClientId); postData.Add("client_secret", ClientSecret); // Initialize the request SocialHttpRequest request = new SocialHttpRequest { Method = SocialHttpMethod.Post, Url = "https://accounts.spotify.com/api/token", PostData = postData }; // Make a call to the server SocialHttpResponse response = request.GetResponse(); // Parse the JSON response return(SpotifyTokenResponse.ParseResponse(response)); }
/// <summary> /// Exchanges the specified authorization code for an access token. /// </summary> /// <param name="authCode">The authorization code received from the Vimeo OAuth dialog.</param> /// <returns>An instance of <see cref="VimeoTokenResponse"/> representing the response.</returns> public VimeoTokenResponse GetAccessTokenFromAuthCode(string authCode) { // Some validation if (String.IsNullOrWhiteSpace(ClientId)) { throw new PropertyNotSetException(nameof(ClientId)); } if (String.IsNullOrWhiteSpace(ClientSecret)) { throw new PropertyNotSetException(nameof(ClientSecret)); } if (String.IsNullOrWhiteSpace(RedirectUri)) { throw new PropertyNotSetException(nameof(RedirectUri)); } if (String.IsNullOrWhiteSpace(authCode)) { throw new ArgumentNullException(nameof(authCode)); } // Initialize the POST data IHttpPostData data = new SocialHttpPostData(); data.Add("grant_type", "authorization_code"); data.Add("code", authCode); data.Add("redirect_uri", RedirectUri); // Initialize the request SocialHttpRequest request = new SocialHttpRequest { Method = SocialHttpMethod.Post, Url = "https://api.vimeo.com/oauth/access_token", PostData = data, Authorization = "basic " + SecurityUtils.Base64Encode(ClientId + ":" + ClientSecret) }; // Make the call to the API SocialHttpResponse response = request.GetResponse(); // Parse the response return(VimeoTokenResponse.ParseResponse(response)); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> /// <returns>An instance of <see cref="IHttpPostData"/>.</returns> public IHttpPostData GetPostData() { // Validate required properties if (String.IsNullOrWhiteSpace(Status)) { throw new PropertyNotSetException(nameof(Status)); } // Initialize a new instance with required parameters SocialHttpPostData data = new SocialHttpPostData(); data.Set("status", Status); // Append optional parameters to be POST data if (ReplyTo > 0) { data.Add("in_reply_to_status_id", ReplyTo); } if (IsPossiblySensitive) { data.Add("possibly_sensitive", "true"); } if (Math.Abs(Latitude) > Double.Epsilon && Math.Abs(Longitude) > Double.Epsilon) { data.Add("lat", Latitude); data.Add("long", Longitude); } if (PlaceId != null) { data.Add("place_id", PlaceId); } if (DisplayCoordinates) { data.Add("display_coordinates", "true"); } return(data); }
/// <summary> /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters. /// </summary> public IHttpPostData GetPostData() { SocialHttpPostData postData = new SocialHttpPostData(); if (!String.IsNullOrWhiteSpace(Message)) { postData.Add("message", Message); } if (!String.IsNullOrWhiteSpace(Link)) { postData.Add("link", Link); } if (!String.IsNullOrWhiteSpace(Picture)) { postData.Add("picture", Picture); } if (!String.IsNullOrWhiteSpace(Name)) { postData.Add("name", Name); } if (!String.IsNullOrWhiteSpace(Caption)) { postData.Add("caption", Caption); } if (!String.IsNullOrWhiteSpace(Description)) { postData.Add("description", Description); } if (!String.IsNullOrWhiteSpace(Place)) { postData.Add("place", Place); } if (Tags != null && Tags.Length > 0) { postData.Add("tags", String.Join(",", Tags)); } return(postData); }
public IHttpPostData GetPostData() { var data = new SocialHttpPostData { { "steamid", SteamId }, { "umqid", UmqId }, { "message", Message } }; if (PollId != null) { data.Add("pollid", PollId); } if (SecTimeout != null) { data.Add("sectimeout", SecTimeout); } if (SecIdleTime != null) { data.Add("secidletime", SecIdleTime); } if (UseAccountIds != null) { data.Add("use_accountids", UseAccountIds); } return(data); }