Search code examples
c#twittertwitterizer

How to send tweet to target user?


I have some code:

  internal TwitterResponse<TwitterStatus> UpdateTweet(string Tweet)
        {
            TwitterResponse<TwitterStatus> tweetResponse = null;

             OAuthTokens tokens = new OAuthTokens();

             tokens.AccessToken = accessToken;
             tokens.AccessTokenSecret = accessTokenSecret;
             tokens.ConsumerKey = consumerKey;
             tokens.ConsumerSecret = consumerSecret;


             tweetResponse = TwitterStatus.Update(tokens, Tweet);


            return tweetResponse;
        }

This code send tweet to authenticated user but I need send to assigned user.


Solution

  • The tweet text should begin with "@<username>" to direct a tweet to a specific person. Keep in mind that this is still a public tweet (provided that the authenticated user is not protected). To send a private message from the authenticated user to another user, you can use the TwitterDirectMessage class or prefix a tweet with "d <username>".

    So, to send a public tweet that is directed to a user, do like: @twit_er_izer Just wanted to say hello.

    To send a direct message, do like: d twit_er_izer Just wanted to say hello.
    (Or use the direct message class.)