예제 #1
0
        public static void TwitterToNeo4J()
        {
            var auth = new TwitterAuth(
                "nYy5AhN7oiGMHYtSZwuovXsud",
                "40U6Vn9KbACfwKhZUCyNEBuP7XiOoDmrbTTkV0Bah6YdJHtbWF",
                "1259825000-AzHEC4d37thxV5YyNxo7QGEllzDmJHbADPVNbsn",
                "aYFtTTtBdjnLAjWciD8wJBjomDKlaSqwAnWTscm9cPiMr"
                );

            var t = new TwitterNeo4J();

            try {
                var api = new TwitterApi(auth);

                var tweets     = api.GetTimelineForUser(InitialUserId);
                var tweetArray = tweets as ITweet[] ?? tweets.ToArray();

                TwitterUser user = IUserToUser(tweetArray[0].CreatedBy);

                t.InsertUser(user);

                foreach (ITweet iTweet in tweetArray)
                {
                    Tweet tweet = ITweetToTweet(iTweet);

                    t.InsertTweet(tweet);
                    t.AddTweeted(user, tweet);
                }

                foreach (long userId in api.GetAllFollowingForUser(InitialUserId))
                {
                    TwitterUser user2 = IUserToUser(api.getUserFromId(userId));

                    t.InsertUser(user2);

                    t.AddFollowing(user, user2);
                }

                foreach (long userId in api.GetAllFollowersForUser(InitialUserId))
                {
                    TwitterUser user2 = IUserToUser(api.getUserFromId(userId));

                    t.InsertUser(user2);

                    t.AddFollowing(user2, user);
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
            }
        }