示例#1
0
        /// <summary>
        /// Returns all the information about a known place.
        /// </summary>
        /// <param name="placeId">A place in the world. These IDs can be retrieved from ReverseGeocode method.</param>
        /// <returns></returns>
        public TwitterPlace RetrievePlaceById(string placeId)
        {
            if (String.IsNullOrEmpty(placeId))
            {
                throw new ArgumentException();
            }

            var uri = new Uri(this.CommandBaseUri + String.Format("/id/{0}.json", placeId));

            TwitterPlace place = null;

            try
            {
                var response = this.TwitterApi.ExecuteUnauthenticatedRequest(uri);

                place = TwitterObject.Parse <TwitterPlace>(response);
            }
            catch (TwitterException e)
            {
                if (e.StatusCode != HttpStatusCode.NotFound)
                {
                    throw;
                }
            }

            return(place);
        }
示例#2
0
        public void LookupPlaces()
        {
            TwitterPlaceLookupOptions options = new TwitterPlaceLookupOptions
            {
                Granularity = "city",
                MaxResults  = 2
            };

            var places = TwitterPlace.Lookup(30.475012, -84.35509, options);

            Assert.IsNotNull(places.ResponseObject, places.ErrorMessage);
            Assert.AreNotEqual(0, places.ResponseObject.Count, places.ErrorMessage);
            Assert.IsTrue(places.ResponseObject.Count == 2, places.ErrorMessage);
        }
示例#3
0
        public static void LookupPlaces()
        {
            TwitterPlaceLookupOptions options = new TwitterPlaceLookupOptions
            {
                Granularity = "city",
                MaxResults  = 2
            };

            TwitterPlaceCollection places = TwitterPlace.Lookup(30.475012, -84.35509, options).ResponseObject;

            Assert.IsNotNull(places);
            Assert.IsNotEmpty(places);
            Assert.That(places.Count == 2);
        }
示例#4
0
 /// <summary>
 /// Gets information about a place with with the specified ID.
 /// </summary>
 /// <param name="id">The ID of the place.</param>
 /// <see cref="https://dev.twitter.com/docs/api/1.1/get/geo/id/:place_id"/>
 public TwitterPlace GetPlace(string id)
 {
     return(TwitterPlace.ParseJson(Raw.GetPlace(id)));
 }