简体   繁体   English

使用Twitterizer显示出站推文,而不是回复

[英]Using Twitterizer to display the outbound tweets, not replies

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: 我使用Twitterizer在网站上显示推文,但问题是显示所有推文,我只想按用户显示推文,而不是回复,我使用的代码是:

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 上面的代码工作正常,但是我想避免答复,我该怎么做,我已经查看了twitteriser的文档,但找不到任何解决方案,任何建议或帮助将不胜感激,谢谢

The UserTimeLineOptions object allows you to exclude retweets vie the IncludeRetweets property. UserTimeLineOptions对象使您可以排除IncludeRetweets属性中的转发。 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 (ie your account). UserId可帮助twitterAPI找出您仅请求由UserIdScreenName (即您的帐户)的特定组合进行的推文。

I'm not sure if it is completely necessary, but I also send an OAuthTokens object in with the request. 我不确定是否完全必要,但是我还会在请求中发送OAuthTokens对象。

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 . 通过在您的Twitter帐户(位于http://dev.twitter.com)下创建一个应用程序,您可以掌握这些信息。

Then you would include the token in your call: 然后,您将在呼叫中包含令牌:

TwitterTimeline.UserTimeline(token, options);

Hope this helps =) 希望这可以帮助=)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM