Ejemplo n.º 1
0
    /// <summary>
    /// Allows you to check in to a place.
    /// </summary>
    /// <param name="venueId">The venue where the user is checking in. No venueid is needed if shouting or just providing a venue name.</param>
    /// <param name="venue">If are not shouting, but you don't have a venue ID or would rather prefer a 'venueless' checkin</param>
    /// <param name="shout">A message about your check-in. The maximum length of this field is 140 characters.</param>
    /// <param name="Broadcast">Required. How much to broadcast this check-in, ranging from private (off-the-grid) to public,facebook,twitter. Can also be just public or public,facebook, for example. If no valid value is found, the default is public. Shouts cannot be private.</param>
    /// <param name="LL">Latitude and longitude of the user's location. Only specify this field if you have a GPS or other device reported location for the user at the time of check-in.</param>
    public static FourSquareCheckin CheckinAdd(string VenueId, string Venue, string Shout, string Broadcast, string LL, string LLAcc, string Alt, string AltAcc, string AccessToken)
    {
        FourSquareCheckin CheckinResponse = new FourSquareCheckin();

        Dictionary<string, string> parameters = new Dictionary<string, string>();

        if (!Alt.Equals(""))
        {
            parameters.Add("alt", Alt);
        }
        if (!AltAcc.Equals(""))
        {
            parameters.Add("altAcc", AltAcc);
        }
        if (!Broadcast.Equals(""))
        {
            parameters.Add("broadcast", Broadcast);
        }
        if (!LL.Equals(""))
        {
            parameters.Add("ll", LL);
        }
        if (!LLAcc.Equals(""))
        {
            parameters.Add("llAcc", LLAcc);
        }
        if (!Shout.Equals(""))
        {
            parameters.Add("shout", Shout);
        }
        if (!Venue.Equals(""))
        {
            parameters.Add("venue", Venue);
        }
        if (!VenueId.Equals(""))
        {
            parameters.Add("venueId", VenueId);
        }

        parameters.Add("oauth_token", AccessToken);

        HTTPPost POST = new HTTPPost(new Uri("https://api.foursquare.com/v2/checkins/add"), parameters);
        Dictionary<string, object> JSONDictionary = JSONDeserializer(POST.ResponseBody);

        CheckinResponse = new FourSquareCheckin(ExtractDictionary(JSONDictionary, "response:checkin"));

        foreach (object Obj in (object[])JSONDictionary["notifications"])
        {
            FourSquareNotification Notification = new FourSquareNotification((Dictionary<string, object>)Obj);
            CheckinResponse.notifications.Add(Notification);
        }
        return CheckinResponse;
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows you to check in to a place.
        /// </summary>
        /// <param name="venueId">The venue where the user is checking in. No venueid is needed if shouting or just providing a venue name.</param>
        /// <param name="venue">If are not shouting, but you don't have a venue ID or would rather prefer a 'venueless' checkin</param>
        /// <param name="shout">A message about your check-in. The maximum length of this field is 140 characters.</param>
        /// <param name="broadcast">Required. How much to broadcast this check-in, ranging from private (off-the-grid) to public,facebook,twitter. Can also be just public or public,facebook, for example. If no valid value is found, the default is public. Shouts cannot be private.</param>
        /// <param name="ll">Latitude and longitude of the user's location. Only specify this field if you have a GPS or other device reported location for the user at the time of check-in.</param>
        /// <param name="llAcc">Accuracy of the user's latitude and longitude, in meters.</param>
        /// <param name="alt">Altitude of the user's location, in meters.</param>
        /// <param name="altAcc">Vertical accuracy of the user's location, in meters.</param>
        public static FourSquareCheckin CheckinAdd(string venueId, string venue, string shout, string broadcast, string ll, string llAcc, string alt, string altAcc, string AccessToken)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();

            if (!alt.Equals(""))
            {
                parameters.Add("alt", alt);
            }
            if (!altAcc.Equals(""))
            {
                parameters.Add("altAcc", altAcc);
            }
            if (!broadcast.Equals(""))
            {
                parameters.Add("broadcast", broadcast);
            }
            if (!ll.Equals(""))
            {
                parameters.Add("ll", ll);
            }
            if (!llAcc.Equals(""))
            {
                parameters.Add("llAcc", llAcc);
            }
            if (!shout.Equals(""))
            {
                parameters.Add("shout", shout);
            }
            if (!venue.Equals(""))
            {
                parameters.Add("venue", venue);
            }
            if (!venueId.Equals(""))
            {
                parameters.Add("venueId", venueId);
            }
            parameters.Add("callback", "XXX");
            parameters.Add("v", Version);
            parameters.Add("oauth_token", AccessToken);

            string strURL = "https://api.foursquare.com/v2/checkins/add?oauth_token=" + AccessToken;
            strURL += "&broadcast=" + broadcast;
            strURL += "&venueId=" + venueId;
            HTTPPost POST = new HTTPPost(new Uri(strURL), parameters);
            Dictionary<string, object> JSONDictionary = JSONDeserializer(POST.ResponseBody);
            FourSquareCheckin CheckinResponse = new FourSquareCheckin(JSONDictionary);
            return CheckinResponse;
        }
Ejemplo n.º 3
0
            public FourSquarePhoto(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                JSONDictionary = ExtractDictionary(JSONDictionary, "response:photo");
                id = JSONDictionary["id"].ToString();
                createdAt = JSONDictionary["createdAt"].ToString();
                url = JSONDictionary["url"].ToString();

                if (JSONDictionary.ContainsKey("sizes"))
                {
                    foreach (object SizeObj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "sizes"),"items")))
                    {
                        sizes.Add(new FourSquarePhotoSize((Dictionary<string, object>)SizeObj));
                    }
                }

                if (JSONDictionary.ContainsKey("source"))
                {
                    //todo
                }

                if (JSONDictionary.ContainsKey("user"))
                {
                    user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
                }

                if (JSONDictionary.ContainsKey("venue"))
                {
                    venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
                }

                if (JSONDictionary.ContainsKey("tip"))
                {
                    //todo
                }

                if (JSONDictionary.ContainsKey("checkin"))
                {
                    checkin = new FourSquareCheckin((Dictionary<string, object>)JSONDictionary["checkin"]);
                }
            }
Ejemplo n.º 4
0
        /// <summary>
        /// Retrieves information on a specific checkin.
        /// </summary>
        /// <param name="CHECKIN_ID">The ID of the checkin to retrieve specific information for.</param>
        /// <param name="signature">When checkins are sent to public feeds such as Twitter, foursquare appends a signature (s=XXXXXX) allowing users to bypass the friends-only access check on checkins. The same value can be used here for programmatic access to otherwise inaccessible checkins. Callers should use the bit.ly API to first expand 4sq.com links.</param>
        public static FourSquareCheckin CheckinDetails(string CHECKIN_ID, string signature, string AccessToken)
        {
            string Query = "";

            if (!signature.Equals(""))
            {
                if (Query.Equals(""))
                {
                    Query = "?";
                }
                else
                {
                    Query += "&";
                }
                Query += "signature=" + signature;
            }
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            HTTPGet GET = new HTTPGet();
            string EndPoint = "https://api.foursquare.com/v2/checkins/" + CHECKIN_ID + Query + "callback=XXX&v=" + Version + "&oauth_token=" + AccessToken;
            GET.Request(EndPoint);
            Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody);
            FourSquareCheckin Checkin = new FourSquareCheckin(JSONDictionary);
            return Checkin;
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Recent checkins by friends 
    /// </summary>
    /// <param name="ll">Latitude and longitude of the user's location, so response can include distance. "44.3,37.2"</param>
    /// <param name="limit">Number of results to return, up to 100.</param>
    /// <param name="afterTimestamp">Seconds after which to look for checkins</param>
    public static List<FourSquareCheckin> CheckinRecent(string LL, string Limit, string AfterTimestamp, string AccessToken)
    {
        List<FourSquareCheckin> Checkins = new List<FourSquareCheckin>();

        string Query = "";

        if (!LL.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "ll=" + LL;
        }

        if (!Limit.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "limit=" + Limit;
        }

        if (!AfterTimestamp.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "afterTimestamp=" + AfterTimestamp;
        }

        if (Query.Equals(""))
        {
            Query = "?";
        }
        else
        {
            Query += "&";
        }

        HTTPGet GET = new HTTPGet();
        string EndPoint = "https://api.foursquare.com/v2/checkins/recent" + Query + "oauth_token=" + AccessToken;
        GET.Request(EndPoint);
        Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody);
        JSONDictionary = ExtractDictionary(JSONDictionary, "response");
        foreach (object obj in (object[])JSONDictionary["recent"])
        {
            FourSquareCheckin RecentCheckin = new FourSquareCheckin((Dictionary<string, object>)obj);
            Checkins.Add(RecentCheckin);
        }
        return Checkins;
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Retrieves information on a specific checkin.
 /// </summary>
 /// <param name="CHECKIN_ID">The ID of the checkin to retrieve specific information for.</param>
 public static FourSquareCheckin CheckinDetails(string CHECKIN_ID, string AccessToken)
 {
     FourSquareCheckin Checkin = new FourSquareCheckin();
     HTTPGet GET = new HTTPGet();
     string EndPoint = "https://api.foursquare.com/v2/checkins/" + CHECKIN_ID + "?oauth_token=" + AccessToken;
     GET.Request(EndPoint);
     Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody);
     JSONDictionary = ExtractDictionary(JSONDictionary, "response:checkin");
     Checkin = new FourSquareCheckin(JSONDictionary);
     return Checkin;
 }