Exemple #1
0
        public string Follow(string userName, string Nick, string screenName)
        {
            var twitterSecret = new TwitterSecretData(userName, Nick);
            var service       = new TwitterService(twitterSecret._OAuthConsumerKey, twitterSecret._OAuthConsumerSecret);

            service.AuthenticateWith(twitterSecret._OAuthAccessToken, twitterSecret._OAuthAccessTokenSecret);
            FollowUserOptions _FollowUserOptions = new TweetSharp.FollowUserOptions();

            _FollowUserOptions.ScreenName = screenName;
            service.FollowUser(_FollowUserOptions);
            return("Followed successfully!");
        }
Exemple #2
0
        public static bool unfollowUser(AccountTwitter account, string username)
        {
            FollowUserOptions options = new TweetSharp.FollowUserOptions();

            options.ScreenName = username;
            options.Follow     = false;
            TwitterUser user = account.twitterService.FollowUser(options);

            if (user != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
		public virtual void FollowUser(FollowUserOptions options, Action<TwitterUser, TwitterResponse> action)
		{
			var screen_name = options.ScreenName;
			var user_id = options.UserId;
			var follow = options.Follow;
			
			WithHammock(WebMethod.Post, action, "friendships/create", FormatAsString, "?screen_name=", screen_name, "&user_id=", user_id, "&follow=", follow);
		}
		public virtual IAsyncResult BeginFollowUser(FollowUserOptions options)
		{
			var screen_name = options.ScreenName;
			var user_id = options.UserId;
			var follow = options.Follow;
				

			return BeginWithHammock<TwitterUser>(WebMethod.Post, "friendships/create", FormatAsString, "?screen_name=", screen_name, "&user_id=", user_id, "&follow=", follow);
		}
		public virtual Task<TwitterResponse<TwitterUser>> FollowUserAsync(FollowUserOptions options)
		{
			var screen_name = options.ScreenName;
			var user_id = options.UserId;
			var follow = options.Follow;
				
			
			return ExecuteRequest<TwitterUser>(HttpMethod.Post, "friendships/create", FormatAsString, "?screen_name=", screen_name, "&user_id=", user_id, "&follow=", follow);
		}
        /// <summary>
        /// Follows/unfollows a twitter user
        /// </summary>
        private void FollowUser(string command)
        {
            if (command.Split(' ')[1].Length != 2 && command.Split(' ')[1].StartsWith("@") == false)
            {
                ScreenDraw.ShowMessage("Wrong syntax. Use /follow [id] or /follow @[name]");
            }
            else
            {
                string screenName = "";
                if (command.Split(' ')[1].StartsWith("@"))
                {
                    screenName = command.Split(' ')[1].Remove(0, 1);
                }
                else
                {
                    try
                    {
                        long tweetID = Convert.ToInt64(TweetIdentification.GetTweetID(command.Split(' ')[1]).InReplyToStatusId);
                        InteractiveTweet tweet = TweetIdentification.FindTweet(tweetID);
                        screenName = tweet.AuthorScreenName;
                    }
                    catch (KeyNotFoundException exIn)
                    {
                        ScreenDraw.ShowMessage(exIn.Message);
                    }
                }

                if (GetUpdates.IsFollowing(screenName))
                {
                    UnfollowUserOptions unfollowOpts = new UnfollowUserOptions();
                    unfollowOpts.ScreenName = screenName;
                    User.Account.UnfollowUser(unfollowOpts);
                    if (User.Account.Response.Error == null)
                    {
                        ScreenDraw.ShowMessage("Successfully unfollowed @" + screenName);
                    }
                    else
                    {
                        ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message);
                    }
                }
                else
                {
                    FollowUserOptions followOpts = new FollowUserOptions();
                    followOpts.ScreenName = screenName;
                    User.Account.FollowUser(followOpts);
                    if (User.Account.Response.Error == null)
                    {
                        ScreenDraw.ShowMessage("Successfully followed @" + screenName);
                    }
                    else
                    {
                        ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message);
                    }
                }
            }
        }