/// <summary>
        /// Retrieves a place based on the specified coordinates.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="options">The options.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <returns></returns>
        public static IAsyncResult Lookup(
            double latitude, 
            double longitude,
            TwitterPlaceLookupOptions options, 
            TimeSpan timeout,
            Action<TwitterAsyncResponse<TwitterPlaceCollection>> function)
        {
            Func<double, double, TwitterPlaceLookupOptions, TwitterResponse<TwitterPlaceCollection>> methodToCall = TwitterPlace.Lookup;

            return methodToCall.BeginInvoke(
                latitude,
                longitude,
                options,
                result =>
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterPlaceCollection>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
        }
        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);
        }
        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);
        }
Exemple #4
0
        /// <summary>
        /// Retrieves a place based on the specified coordinates.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="options">The options.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <returns></returns>
        public static IAsyncResult Lookup(
            double latitude,
            double longitude,
            TwitterPlaceLookupOptions options,
            TimeSpan timeout,
            Action <TwitterAsyncResponse <TwitterPlaceCollection> > function)
        {
            Func <double, double, TwitterPlaceLookupOptions, TwitterResponse <TwitterPlaceCollection> > methodToCall = TwitterPlace.Lookup;

            return(methodToCall.BeginInvoke(
                       latitude,
                       longitude,
                       options,
                       result => AsyncUtility.ThreeParamsNoTokenCallback(result, timeout, methodToCall, function),
                       null));
        }
        /// <summary>
        /// Retrieves a place based on the specified coordinates.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="options">The options.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <returns></returns>
        public static IAsyncResult Lookup(
            double latitude, 
            double longitude,
            TwitterPlaceLookupOptions options, 
            TimeSpan timeout,
            Action<TwitterAsyncResponse<TwitterPlaceCollection>> function)
        {
            Func<double, double, TwitterPlaceLookupOptions, TwitterResponse<TwitterPlaceCollection>> methodToCall = TwitterPlace.Lookup;

            return methodToCall.BeginInvoke(
                latitude,
                longitude,
                options,
                result => AsyncUtility.ThreeParamsNoTokenCallback(result, timeout, methodToCall, function),
                null);
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (!(TextBox1.Text == "" || TextBox1.Text == null))
            {
                OAuthTokens token = new OAuthTokens();
                token.AccessToken = Session["tokenS"].ToString();
                token.AccessTokenSecret = Session["Atoken"].ToString();
                token.ConsumerKey = clid;
                token.ConsumerSecret = clsec;
                lat = double.Parse(HiddenField1.Value);
                lng = double.Parse(HiddenField2.Value);
                StatusUpdateOptions sou = new StatusUpdateOptions();
                sou.Latitude = lat;
                sou.Longitude = lng;
                TwitterPlaceLookupOptions tplo = new TwitterPlaceLookupOptions();
                tplo.MaxResults = 1;

                TwitterResponse<TwitterPlaceCollection> tc = TwitterPlace.Lookup(lat, lng, tplo);
                if (tc.Result == RequestResult.Success)
                {
                    foreach (var s in tc.ResponseObject)
                    {
                        sou.PlaceId = s.Id;
                    }
                }
                TwitterResponse<TwitterStatus> tweetstatus = TwitterStatus.Update(token, TextBox1.Text, sou);
                if (tweetstatus.Result == RequestResult.Success)
                {
                    Label6.Text = "Your message was posted successfully";

                }
                else
                {
                    Label6.Text = "Something went Wrong, Your Tweet wasn't Updated";
                }
            }
            else
            {
            }
        }
        catch
        {
            Label6.Text = "Tweet Update Failed, Please Try Again";
        }
    }
        /// <summary>
        /// Retrieves a place based on the specified coordinates.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="options">The options.</param>
        /// <returns>A collection of matched <see cref="Twitterizer.TwitterPlace"/> items.</returns>
        public static TwitterResponse<TwitterPlaceCollection> Lookup(double latitude, double longitude, TwitterPlaceLookupOptions options)
        {
            Commands.ReverseGeocodeCommand command = new Twitterizer.Commands.ReverseGeocodeCommand(latitude, longitude, options);

            return CommandPerformer.PerformAction(command);
        }
Exemple #8
0
        /// <summary>
        /// Retrieves a place based on the specified coordinates.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="options">The options.</param>
        /// <returns>A collection of matched <see cref="Twitterizer.TwitterPlace"/> items.</returns>
        public static TwitterResponse <TwitterPlaceCollection> Lookup(double latitude, double longitude, TwitterPlaceLookupOptions options)
        {
            Commands.ReverseGeocodeCommand command = new Twitterizer.Commands.ReverseGeocodeCommand(latitude, longitude, options);

            return(CommandPerformer.PerformAction(command));
        }
Exemple #9
0
 /// <summary>
 /// Retrieves a place based on the specified coordinates.
 /// </summary>
 /// <param name="latitude">The latitude.</param>
 /// <param name="longitude">The longitude.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>A collection of matched <see cref="Twitterizer.TwitterPlace"/> items.</returns>
 public static async Task<TwitterResponse<PlaceCollection>> ReverseGeocodeAsync(double latitude, double longitude, TwitterPlaceLookupOptions options = null)
 {
     return await Core.CommandPerformer.PerformAction(new Twitterizer.Commands.ReverseGeocodeCommand(latitude, longitude, options));
 }        
Exemple #10
0
 /// <summary>
 /// Retrieves a place based on the specified coordinates.
 /// </summary>
 /// <param name="latitude">The latitude.</param>
 /// <param name="longitude">The longitude.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>A collection of matched <see cref="Twitterizer.TwitterPlace"/> items.</returns>
 public static async Task <TwitterResponse <PlaceCollection> > ReverseGeocodeAsync(double latitude, double longitude, TwitterPlaceLookupOptions options = null)
 {
     return(await Core.CommandPerformer.PerformAction(new Twitterizer.Commands.ReverseGeocodeCommand(latitude, longitude, options)));
 }