Get Tweets and geo locations of tweets by keywords.

Nov 5, 2014 at 1:35 PM
Edited Nov 5, 2014 at 1:36 PM
I am trying to get tweets and geo location of different tweets by keyword using Streaming Api.I am beginner at this so i tried but after start debugging it just shows a blank console.Can you help me with this or point me to the right direction.
 private const string USER_SCREEN_NAME_TO_TEST = "ladygaga";
        static void Main()
            TwitterCredentials.SetCredentials("xxxx", "xxxx", "xxxx", "xxxx");


        private static void Stream_FilteredStreamExample()
            var stream = Stream.CreateFilteredStream();
            var location = Geo.GenerateLocation(-124.75, 36.8, -126.89, 32.75);


            stream.MatchingTweetAndLocationReceived += (sender, args) =>
                var tweet = args.Tweet;
                Console.WriteLine("{0} was detected between the following tracked locations:", tweet.Id);

                IEnumerable<ILocation> matchingLocations = args.MatchedLocations;
                foreach (var matchingLocation in matchingLocations)
                    Console.Write("({0}, {1}) ;", matchingLocation.Coordinate1.Latitude, matchingLocation.Coordinate1.Longitude);
                    Console.WriteLine("({0}, {1})", matchingLocation.Coordinate2.Latitude, matchingLocation.Coordinate2.Longitude);


Nov 5, 2014 at 2:42 PM

The reason why this is not working might be because no tweet published matches both the location and the search.
What you can do to verify this is use StartStreamMatchingAnyCondition instead of StartStreamMatchingAllConditions;
You can then check whether the information any tweet is being received from Twitter using the JSonObjectReceived, that will give you the RAW Json of each object received from Twitter.
stream.JsonObjectReceived += (sender, args) => { Console.WriteLine(args.Json); };
Please let me know if any of this helped you.
Nov 5, 2014 at 3:49 PM
Thank you for your quick reply.

i used the JsonObjectReceived and got the console with everything.It is really messy to see all of those.can you suggest me how can i modify to only write line with text, location and timezone of the received tweet.
Nov 6, 2014 at 1:21 PM
Hi there,

I was asking this question in order to detect whether your restrictions are too important and it seems to be the case.

Please try to add conditions of a single specific type (Track/Location/Follower). I believe the stream will return results.
Your problem only comes from the fact that people in the specified Location are not often tweeting about the subjects you specified.

Nov 26, 2014 at 2:21 AM
Hi Linvi,

Everything works fines with the first code after i modify my location coordinate to (-180,-90,180,90) but i only get tweets from coordinate (-180,-90,180,90). Now i want to track location with multiple coordinates i.e. of different city or country. for e.g. india( 21.0000° N, 78.0000° E) and china(35.0000° N, 103.0000° E).
can you help me how i can track multiple location.
also can u help me understand what coordinate (-180,-90,180,90) stands for?


Nov 26, 2014 at 12:54 PM

These coordinates represents the "center" of the planet on a flat map.
I think you ought to have a look on wikipedia to have a better understanding of the coordinates system.

In order to track tweets from multiple location you need to specify 2 coordinates that represent the top-left and the bottom-right of location box.
var location = Geo.GenerateLocation(left, top, right, bottom);

var fs = Stream.CreateFilteredStream();