Esempio n. 1
0
        public static TwitterUser[] GetFollowersFor(string sUsername)
        {
            // Pass your credentials to the service
            TwitterService service = new TwitterService("g0fsdKhJObiZLamY2P7vfg", "ghUKQ9y0LvN08clZq6wwU41a0gMlrv9oGj9zd55292w");

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            //Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            string verifier = "123456"; // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);
            access.TokenSecret = "6CFvw63PNUNx4cbj53n5idwlaRUVSz9lKNhr8FM";
            access.Token = "14820993-dEh4f6mD1RNSe1pp8ZmKwJb9g0TGyyGqyHuvZsM9s";

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
            TwitterCursorList<TwitterUser> followersList = null;
            TwitterCursorList<TwitterUser> list = service.ListFollowersOf(sUsername, -1);
            long? nextCursor = list.NextCursor;

            followersList = new TwitterCursorList<TwitterUser>(list);

            while ((nextCursor ?? 0) != 0)
            {
                TwitterCursorList<TwitterUser> tempFollowersList = service.ListFollowersOf(sUsername, (long)nextCursor);
                if (tempFollowersList.Count <= 0)
                    break;

               followersList.AddRange(tempFollowersList);

               nextCursor = tempFollowersList.NextCursor;
            }

            TwitterUser[] array = new TwitterUser[followersList.Count];
            followersList.CopyTo(array);
            return array;
        }