0

Ia m using twitterizer to diplay tweets on the website , but the issue its showing all the tweets ,i just want to show the tweets by user not the replies, the code i am using is:

if (!Page.IsPostBack)
        {
            try
            {

            UserTimelineOptions options = new UserTimelineOptions();
            options.ScreenName = "XXXXX";

            TwitterStatusCollection tweets = TwitterTimeline.UserTimeline(options).ResponseObject;
            int counter = 0;
            string TwitterCode = "";     

            foreach (TwitterStatus thisStatus in tweets)
            {
                if (counter < 7)
                {
                    DateTime completeDate = thisStatus.CreatedDate;
                    string complete = completeDate.ToLongDateString();
                    TwitterCode += "<li><p ><a href=\"http://twitter.com/" + thisStatus.User.ScreenName + "\" target=\"_blank\" >" + Server.HtmlEncode(thisStatus.Text) + "<br/><span style=\"color:#E87D05;\">" +  complete + "</a></p></li>";
                    counter += 1;

                }
                else
                {
                    break;
                }

            }

            ltlTweets.Text = TwitterCode;


        }
        catch (Exception ex)
        {

        }

        }

The above code works fine but i want to avoid the replies , how can i do that i have gone through documentation of twitteriser but couldnt find any solution for it , Anysuggestions or help will be appreciated Thanks

Mr A
  • 6,448
  • 25
  • 83
  • 137

1 Answers1

0

The UserTimeLineOptions object allows you to exclude retweets vie the IncludeRetweets property. Like so:

UserTimelineOptions options = new UserTimelineOptions()
{
    ScreenName = "myname",
    UserId = 123456789,
    IncludeRetweets = false,
    Count = 10,
};

The UserId helps the twitterAPI figure out that you are only requesting tweets made by that specific combination of UserId and ScreenName (i.e your account).

I'm not sure if it is completely necessary, but I also send an OAuthTokens object in with the request.

OAuthTokens token = new OAuthTokens()
{
    AccessToken = "xx",
    AccessTokenSecret = "xx",
    ConsumerKey = "xx",
    ConsumerSecret = "xx"
};

You would get hold of this information by creating an app under your twitter account at http://dev.twitter.com.

Then you would include the token in your call:

TwitterTimeline.UserTimeline(token, options);

Hope this helps =)

AutoGibbon
  • 147
  • 2
  • 8