Beispiel #1
0
        private FourSquareSingleResponse <T> GetSingle <T>(string endpoint, Dictionary <string, string> parameters, bool unauthenticated) where T : FourSquareEntity
        {
            string serializedParameters = "";

            if (parameters != null)
            {
                serializedParameters = "&" + SerializeDictionary(parameters);
            }

            string oauthToken = "";

            if (unauthenticated)
            {
                oauthToken = string.Format("client_id={0}&client_secret={1}", clientId, clientSecret);
            }
            else
            {
                oauthToken = string.Format("oauth_token={0}", accessToken);
            }

            string json = Request(string.Format("{0}{1}?{2}{3}&v={4}", apiUrl, endpoint, oauthToken, serializedParameters, apiVersion), HttpMethod.GET);
            FourSquareSingleResponse <T> fourSquareResponse = JsonConvert.DeserializeObject <FourSquareSingleResponse <T> >(json);

            return(fourSquareResponse);
        }
Beispiel #2
0
        private FourSquareSingleResponse <T> Post <T>(string endpoint) where T : FourSquareEntity
        {
            string serializedParameters = "";

            string json = Request(string.Format("{0}{1}?oauth_token={2}{3}&v={4}", apiUrl, endpoint, accessToken, serializedParameters, apiVersion), HttpMethod.POST);
            FourSquareSingleResponse <T> fourSquareResponse = JsonConvert.DeserializeObject <FourSquareSingleResponse <T> >(json);

            return(fourSquareResponse);
        }
Beispiel #3
0
        private FourSquareSingleResponse <T> Post <T>(string endpoint, Dictionary <string, string> parameters) where T : FourSquareEntity
        {
            string serializedParameters = "";

            if (parameters != null)
            {
                serializedParameters = "&" + SerializeDictionary(parameters);
            }

            string json = Request(string.Format("{0}{1}?oauth_token={2}{3}", apiUrl, endpoint, accessToken, serializedParameters), HttpMethod.POST);
            FourSquareSingleResponse <T> fourSquareResponse = JsonConvert.DeserializeObject <FourSquareSingleResponse <T> >(json);

            return(fourSquareResponse);
        }
        // User
        /// <summary>
        ///     https://api.foursquare.com/v2/users/USER_ID
        ///     Returns profile information for a given user, including selected badges and mayorships.
        ///     If the user is a friend, contact information, Facebook ID, and Twitter handle and the user's last checkin may also
        ///     be present.
        ///     In addition, the pings field will indicate whether checkins from this user will trigger a ping (notifications to
        ///     mobile devices). This setting can be changed via setpings. Note that this setting is overriden if pings is false in
        ///     settings (no pings will be sent, even if this user is set to true).
        /// </summary>
        public async Task <User> GetUser(string userId)
        {
            FourSquareSingleResponse <User> user = await this.GetSingle <User>("/users/" + userId);

            return(user.response["user"]);
        }