コード例 #1
0
        static void Main(string[] args)
        {
            string accessToken = "874229294-vTpHJDcl8K0I7Ae6H29Ezvpw5ZVsX3uT2wbtDNkD";
            string accessTokenSecret = "3XNHrHBanj3x2fOTCm53t7L6hd7NSDlLqWIgc24um3x83";
            string customerKey = "kO6JlIwLa4czaQSqvHXLFfOhb";
            string customerSecret = "rSbhwvMR0vq1UCpkztfl3PvazveNHCKg6879J8yd0kLu7Q0xSF";

            var config = new StreamConfig()
            {
                ConsumerKey = customerKey,
                ConsumerSecret = customerSecret,
                AccessToken = accessToken,
                AccessSecret = accessTokenSecret,
                GeoOnly = true
            };
            var stream = new TwitterStreamClient(config);

            // subscribe to the event handler
            stream.TweetReceivedEvent += (sender, arguments) =>
            {
                Console.WriteLine(arguments.Tweet.coordinates);
            };

            stream.ExceptionReceived += (sender, exception) => Console.WriteLine(exception.TwitterException.ResponseMessage);

            stream.Start();
        }
コード例 #2
0
        public TwitterConnection()
        {
            _context = GlobalHost.ConnectionManager.GetHubContext<TwitterHub>();
            var config = new StreamConfig()
            {
                ConsumerKey = _consumerKey,
                ConsumerSecret = _consumerSecret,
                AccessToken = _accessKey,
                AccessSecret = _accessToken,
                GeoOnly = true
            };
            var stream = new TwitterStreamClient(config);

            stream.TweetReceivedEvent += (sender, args) =>
            {
                Debug.WriteLine(args.Tweet.ToString());
                _context.Clients.All.broadcast(args.Tweet);
            };
            stream.Start();
        }