コード例 #1
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("appid", AppId);
            return(qs);
        }
コード例 #2
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        /// <returns>An instance of <see cref="IHttpQueryString"/>.</returns>
        public IHttpQueryString GetQueryString()
        {
            SocialHttpQueryString qs = new SocialHttpQueryString();

            if (UserId > 0)
            {
                qs.Set("user_id", UserId);
            }
            if (!String.IsNullOrWhiteSpace(ScreenName))
            {
                qs.Set("screen_name", ScreenName);
            }
            if (Count > 0)
            {
                qs.Set("count", Count);
            }
            if (Cursor > 0)
            {
                qs.Set("cursor", Cursor);
            }
            if (FilterToOwnedLists)
            {
                qs.Set("filter_to_owned_lists", "1");
            }
            return(qs);
        }
コード例 #3
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("addr", Addr);
            return(qs);
        }
コード例 #4
0
        /// <summary>
        /// Generates the authorization URL using the specified <paramref name="state"/>.
        /// </summary>
        /// <param name="state">The state to send to the Sonos OAuth login page.</param>
        /// <returns>An authorization URL based on <paramref name="state"/>.</returns>
        public string GetAuthorizationUrl(string state)
        {
            // Input validation
            if (String.IsNullOrWhiteSpace(ClientId))
            {
                throw new PropertyNotSetException(nameof(ClientId));
            }
            if (String.IsNullOrWhiteSpace(RedirectUri))
            {
                throw new PropertyNotSetException(nameof(RedirectUri));
            }

            // Do we have a valid "state" ?
            if (String.IsNullOrWhiteSpace(state))
            {
                throw new ArgumentNullException(nameof(state), "A valid state should be specified as it is part of the security of OAuth 2.0.");
            }

            // Construct the query string
            IHttpQueryString query = new SocialHttpQueryString {
                { "client_id", ClientId },
                { "redirect_uri", RedirectUri },
                { "response_type", "code" },
                { "scope", "playback-control-all" },
                { "state", state }
            };

            // Construct the authorization URL
            return("https://api.sonos.com/login/v3/oauth?" + query);
        }
コード例 #5
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        /// <returns>An instance of <see cref="IHttpQueryString"/>.</returns>
        public IHttpQueryString GetQueryString()
        {
            SocialHttpQueryString qs = new SocialHttpQueryString();

            if (UserId > 0)
            {
                qs.Set("user_id", UserId);
            }
            if (!String.IsNullOrWhiteSpace(ScreenName))
            {
                qs.Set("screen_name", ScreenName);
            }
            if (Cursor != DefaultCursor)
            {
                qs.Set("cursor", Cursor);
            }
            if (Count != DefaultCount)
            {
                qs.Set("count", Count);
            }
            if (SkipStatus != DefaultSkipStatus)
            {
                qs.Set("skip_status", SkipStatus ? "1" : "0");
            }
            if (IncludeUserEntities != DefaultIncludeUserEntities)
            {
                qs.Set("include_user_entities", IncludeUserEntities ? "1" : "0");
            }
            return(qs);
        }
コード例 #6
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        public IHttpQueryString GetQueryString()
        {
            if (AppId == 0)
            {
                throw new PropertyNotSetException(nameof(AppId));
            }

            IHttpQueryString qs = new SocialHttpQueryString();

            qs.Set("appid", AppId);
            if (MaxLength > 0)
            {
                qs.Set("maxlength", MaxLength);
            }
            if (EndDate != null)
            {
                qs.Set("enddate", EndDate);
            }
            if (Count > 0)
            {
                qs.Set("count", Count);
            }
            if (Feeds != null && Feeds.Length > 0)
            {
                qs.Set("feeds", String.Join(",", Feeds));
            }

            return(qs);
        }
コード例 #7
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        /// <returns>An instance of <see cref="IHttpQueryString"/>.</returns>
        public IHttpQueryString GetQueryString()
        {
            if (Id == 0)
            {
                throw new PropertyNotSetException(nameof(Id));
            }

            SocialHttpQueryString query = new SocialHttpQueryString();

            query.Set("id", Id);
            if (TrimUser)
            {
                query.Add("trim_user", "true");
            }
            if (IncludeMyRetweet)
            {
                query.Add("include_my_retweet", "true");
            }
            if (IncludeEntities)
            {
                query.Add("include_entities", "true");
            }
            if (TweetMode != TwitterTweetMode.Compatibility)
            {
                query.Add("tweet_mode", StringUtils.ToCamelCase(TweetMode));
            }
            return(query);
        }
コード例 #8
0
        public IHttpQueryString GetQueryString()
        {
            // Initialize the query string
            SocialHttpQueryString query = new SocialHttpQueryString();

            // Set required parameters
            query.Set("lat", Latitude);
            query.Set("long", Longitude);

            // Set optional parameters
            if (Accurary != null && Accurary != "0m")
            {
                query.Set("accuracy", Accurary);
            }
            if (Granularity != default(TwitterGranularity))
            {
                query.Set("granularity", Granularity.ToString().ToLower());
            }
            if (MaxResults > 0)
            {
                query.Set("max_results", MaxResults);
            }

            return(query);
        }
コード例 #9
0
        /// <summary>
        /// Gets an authorization URL using the specified <paramref name="state"/> and request the specified
        /// <paramref name="scope"/>.
        /// </summary>
        /// <param name="state">A unique state for the request.</param>
        /// <param name="scope">The scope of your application.</param>
        /// <returns>The authorization URL.</returns>
        public virtual string GetAuthorizationUrl(string state, params string[] scope)
        {
            // Some validation
            if (String.IsNullOrWhiteSpace(ClientId))
            {
                throw new PropertyNotSetException("ClientId");
            }
            if (String.IsNullOrWhiteSpace(RedirectUri))
            {
                throw new PropertyNotSetException("RedirectUri");
            }

            // Do we have a valid "state" ?
            if (String.IsNullOrWhiteSpace(state))
            {
                throw new ArgumentNullException("state", "A valid state should be specified as it is part of the security of OAuth 2.0.");
            }

            // Construct the query string
            IHttpQueryString query = new SocialHttpQueryString();

            query.Add("client_id", ClientId);
            query.Add("redirect_uri", RedirectUri);
            query.Add("response_type", "code");
            query.Add("state", state);

            // Append the scope (if specified)
            if (scope != null && scope.Length > 0)
            {
                query.Add("scope", String.Join(" ", scope));
            }

            // Construct the authorization URL
            return("https://api.instagram.com/oauth/authorize/?" + query.ToString());
        }
コード例 #10
0
        /// <summary>
        /// Generates the authorization URL using the specified <paramref name="state"/> and <paramref name="scope"/>.
        /// </summary>
        /// <param name="state">The state to send to Vimeo's OAuth login page.</param>
        /// <param name="scope">The scope of the application.</param>
        /// <returns>An authorization URL based on <see cref="ClientId"/>, <see cref="RedirectUri"/>,
        /// <paramref name="state"/> and <paramref name="scope"/>.</returns>
        public string GetAuthorizationUrl(string state, string scope = null)
        {
            // Validate the input
            if (String.IsNullOrWhiteSpace(state))
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (String.IsNullOrWhiteSpace(ClientId))
            {
                throw new PropertyNotSetException(nameof(ClientId));
            }
            if (String.IsNullOrWhiteSpace(RedirectUri))
            {
                throw new PropertyNotSetException(nameof(RedirectUri));
            }

            // Construct the query string
            IHttpQueryString query = new SocialHttpQueryString();

            query.Add("response_type", "code");
            query.Add("client_id", ClientId);
            query.Add("redirect_uri", RedirectUri);
            query.Add("scope", scope + "");
            query.Add("state", state);

            // Construct the full URL
            return("https://api.vimeo.com/oauth/authorize?" + query);
        }
コード例 #11
0
        /// <summary>
        /// Generates the authorization URL using the specified <paramref name="state"/> and <paramref name="scope"/>.
        /// </summary>
        /// <param name="state">The state to send to the Spotify OAuth login page.</param>
        /// <param name="scope">The scope of the application.</param>
        /// <returns>An authorization URL based on <paramref name="state"/> and <paramref name="scope"/>.</returns>
        public string GetAuthorizationUrl(string state, params string[] scope)
        {
            // Input validation
            if (String.IsNullOrWhiteSpace(ClientId))
            {
                throw new PropertyNotSetException(nameof(ClientId));
            }
            if (String.IsNullOrWhiteSpace(RedirectUri))
            {
                throw new PropertyNotSetException(nameof(RedirectUri));
            }

            // Do we have a valid "state" ?
            if (String.IsNullOrWhiteSpace(state))
            {
                throw new ArgumentNullException(nameof(state), "A valid state should be specified as it is part of the security of OAuth 2.0.");
            }

            // Construct the query string
            IHttpQueryString query = new SocialHttpQueryString();

            query.Add("client_id", ClientId);
            query.Add("response_type", "code");
            query.Add("redirect_uri", RedirectUri);
            query.Add("state", state);
            query.Add("scope", String.Join(" ", scope ?? new string[0]));

            // Construct the authorization URL
            return("https://accounts.spotify.com/authorize?" + query);
        }
コード例 #12
0
        public IHttpQueryString GetQueryString()
        {
            SocialHttpQueryString qs = new SocialHttpQueryString();

            if (UserId > 0)
            {
                qs.Set("user_id", UserId);
            }
            if (!String.IsNullOrWhiteSpace(ScreenName))
            {
                qs.Set("screen_name", ScreenName);
            }
            if (Count > 0)
            {
                qs.Set("count", Count);
            }
            if (SinceId > 0)
            {
                qs.Set("since_id", SinceId);
            }
            if (MaxId > 0)
            {
                qs.Set("max_id", MaxId);
            }
            if (!IncludeEntities)
            {
                qs.Set("include_entities", "0");
            }
            return(qs);
        }
コード例 #13
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("leaderboardName", LeaderboardName);
            return(qs);
        }
コード例 #14
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        public IHttpQueryString GetQueryString()
        {
            SocialHttpQueryString qs = new SocialHttpQueryString();

            if (Count > 0)
            {
                qs.Add("count", Count);
            }
            if (MaxTimestamp != null)
            {
                qs.Add("max_timestamp", MaxTimestamp.UnixTimestamp);
            }
            if (MinTimestamp != null)
            {
                qs.Add("min_timestamp", MinTimestamp.UnixTimestamp);
            }
            if (MinId != null)
            {
                qs.Add("min_id", MinId);
            }
            if (MaxId != null)
            {
                qs.Add("max_id", MaxId);
            }
            return(qs);
        }
コード例 #15
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("gameid", GameId);
            return(qs);
        }
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        /// <returns>An instance of <see cref="IHttpQueryString"/>.</returns>
        public IHttpQueryString GetQueryString()
        {
            // Since the name is mandatory, we throw an exception if no specified
            if (String.IsNullOrWhiteSpace(Name))
            {
                throw new PropertyNotSetException("Name");
            }

            // Convert the collection of fields to a string
            string fields = (Fields == null ? "" : Fields.ToString()).Trim();

            // Construct the query string
            SocialHttpQueryString query = new SocialHttpQueryString();

            query.Set("name", Name);
            if (!String.IsNullOrWhiteSpace(Description))
            {
                query.Add("description", Description);
            }
            if (!String.IsNullOrWhiteSpace(fields))
            {
                query.Set("fields", fields);
            }

            return(query);
        }
コード例 #17
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        public IHttpQueryString GetQueryString()
        {
            // Declare the query string
            SocialHttpQueryString qs = new SocialHttpQueryString();

            qs.Add("lat", Latitude);
            qs.Add("lng", Longitude);

            // Optinal options
            if (Distance > 0)
            {
                qs.Add("distance", Distance);
            }
            if (Count > 0)
            {
                qs.Add("count", Count);
            }
            if (MinTimestamp != null)
            {
                qs.Add("min_timestamp", MinTimestamp.UnixTimestamp);
            }
            if (MaxTimestamp != null)
            {
                qs.Add("max_timestamp", MaxTimestamp.UnixTimestamp);
            }

            return(qs);
        }
コード例 #18
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("steamids", SteamIds);
            return(qs);
        }
コード例 #19
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("access_token", AccessToken);
            return(qs);
        }
コード例 #20
0
        /// <summary>
        /// Gets an app access token for for the application. The <see cref="ClientId"/> and <see cref="ClientSecret"/>
        /// properties must be specified for the OAuth client.
        /// </summary>
        /// <returns>Returns an instance of <see cref="FacebookTokenResponse"/> representing the response.</returns>
        public FacebookTokenResponse GetAppAccessToken()
        {
            // Some validation
            if (String.IsNullOrWhiteSpace(Version))
            {
                throw new PropertyNotSetException("Version");
            }
            if (String.IsNullOrWhiteSpace(ClientId))
            {
                throw new PropertyNotSetException("ClientId");
            }
            if (String.IsNullOrWhiteSpace(ClientSecret))
            {
                throw new PropertyNotSetException("ClientSecret");
            }

            // Initialize the query string
            IHttpQueryString query = new SocialHttpQueryString();

            query.Add("client_id", ClientId);
            query.Add("client_secret", ClientSecret);
            query.Add("grant_type", "client_credentials");

            // Make the call to the API
            SocialHttpResponse response = SocialUtils.Http.DoHttpGetRequest("https://graph.facebook.com/" + Version + "/oauth/access_token", query);

            // Parse the response
            return(FacebookTokenResponse.ParseResponse(response));
        }
コード例 #21
0
        /// <summary>
        /// Parses a query string received from the API.
        /// </summary>
        /// <param name="client">The parent OAuth client.</param>
        /// <param name="str">The query string.</param>
        public static SocialOAuthAccessToken Parse(SocialOAuthClient client, string str)
        {
            // Convert the query string to an IHttpQueryString
            IHttpQueryString query = SocialHttpQueryString.ParseQueryString(str);

            // Initialize a new instance
            return(new SocialOAuthAccessToken(client, query));
        }
コード例 #22
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("steamid", SteamId);
            qs.Set("appid_playing", AppIdPlaying);
            return(qs);
        }
コード例 #23
0
        /// <summary>
        /// Parses a query string received from the API.
        /// </summary>
        /// <param name="client">The parent OAuth client.</param>
        /// <param name="str">The query string.</param>
        public new static SocialOAuthRequestToken Parse(SocialOAuthClient client, string str)
        {
            // Convert the query string to a NameValueCollection
            IHttpQueryString query = SocialHttpQueryString.ParseQueryString(str);

            // Initialize a new instance
            return(new TwitterOAuthRequestToken(client, query));
        }
コード例 #24
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("steamid", SteamId);
            qs.Set("relationship", Relationship);
            return(qs);
        }
コード例 #25
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("itemcount", ItemCount);
            qs.Set("publishedfields[0]", PublishedFields);
            return(qs);
        }
コード例 #26
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("collectioncount", CollectionCount);
            qs.Set("publishedfields[0]", PublishedFields);
            return(qs);
        }
コード例 #27
0
        /// <summary>
        /// Favorites the status message with the specified <code>statusId</code> as the authenticating user.
        /// </summary>
        /// <param name="statusId">The ID of the status message.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
        /// <see>
        ///     <cref>https://dev.twitter.com/rest/reference/post/favorites/create</cref>
        /// </see>
        public SocialHttpResponse Create(long statusId)
        {
            // Declare the query string
            SocialHttpQueryString query = new SocialHttpQueryString();

            query.Add("id", statusId);

            // Make the call to the API
            return(Client.DoHttpGetRequest("https://api.twitter.com/1.1/favorites/create.json", query));
        }
コード例 #28
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpQueryString"/> representing the GET parameters.
        /// </summary>
        public IHttpQueryString GetQueryString()
        {
            SocialHttpQueryString qs = new SocialHttpQueryString();

            if (Count > 0)
            {
                qs.Add("count", Count);
            }
            return(qs);
        }
コード例 #29
0
        /// <summary>
        /// Search for tags by name. Results are ordered first as an exact match, then by popularity. Short tags will be treated as exact matches.
        /// </summary>
        /// <param name="tag">A valid tag name without a leading <code>#</code> (eg. <code>snowy</code>, <code>nofilter</code>).</param>
        /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response from the Instagram API.</returns>
        public SocialHttpResponse Search(string tag)
        {
            // Declare the query string
            SocialHttpQueryString qs = new SocialHttpQueryString();

            qs.Add("q", tag);

            // Perform the call to the API
            return(Client.DoHttpGetRequest("https://api.instagram.com/v1/tags/search", qs));
        }
コード例 #30
0
        public IHttpQueryString GetQueryString()
        {
            var qs = new SocialHttpQueryString();

            qs.Set("steamid", SteamId);
            qs.Set("include_appinfo", IncludeAppInfo);
            qs.Set("include_played_free_games", IncludePlayedFreeGames);
            qs.Set("appids_filter", AppIdsFilter);
            return(qs);
        }
コード例 #31
0
        /// <summary>
        /// Makes a HTTP request to the underlying API based on the specified parameters.
        /// </summary>
        /// <param name="method">The HTTP method of the request.</param>
        /// <param name="url">The base URL of the request (no query string).</param>
        /// <param name="queryString">The query string.</param>
        /// <param name="postData">The POST data.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
        public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData postData) {

            // Some input validation
            if (String.IsNullOrWhiteSpace(url)) throw new ArgumentNullException("url");
            if (queryString == null) queryString = new SocialHttpQueryString();
            if (postData == null) postData = new SocialHttpPostData();

            // Initialize the request
            SocialHttpRequest request = new SocialHttpRequest {
                Method = method,
                Url = url,
                QueryString = queryString,
                PostData = postData
            };

            PrepareHttpRequest(request);

            // Make the call to the URL
            return request.GetResponse();

        }