本文整理汇总了C#中TweetSharp.TwitterService.ListTweetsOnUserTimeline方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.ListTweetsOnUserTimeline方法的具体用法?C# TwitterService.ListTweetsOnUserTimeline怎么用?C# TwitterService.ListTweetsOnUserTimeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.ListTweetsOnUserTimeline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTweets
public static IReadOnlyCollection<PoliticalTweet> LoadTweets( IEnumerable<string> handles )
{
var service = new TwitterService( ConsumerKey, ConsumerSecret );
service.AuthenticateWith( AccessToken, AccessTokenSecret );
var results = new List<PoliticalTweet>();
foreach ( var handle in handles.Distinct() )
{
try
{
var response = service.ListTweetsOnUserTimeline( new ListTweetsOnUserTimelineOptions
{
ScreenName = handle,
Count = 200,
IncludeRts = false,
ExcludeReplies = true
} );
results.AddRange( response.Select( t => new PoliticalTweet( handle, t.Text, t.CreatedDate, t.IdStr ) ) );
Debug.WriteLine( $"{service.Response.RateLimitStatus.RemainingHits} remaining hits." );
if ( service.Response.RateLimitStatus.RemainingHits <= 0 )
{
var wait = service.Response.RateLimitStatus.ResetTime.ToUniversalTime() - DateTime.UtcNow;
Debug.WriteLine( $"Rate limit reached. Sleeping for {wait}." );
Thread.Sleep( wait );
}
}
catch
{
Debug.WriteLine( $"Skipping {handle}" );
}
}
return results;
}
示例2: IndexModule
public IndexModule()
{
Get["/locations/{user}", true] = async (paramaters, ct) =>
{
var service = new TwitterService(ConfigurationManager.AppSettings["TWITTER_CONSUMER_KEY"], ConfigurationManager.AppSettings["TWITTER_CONSUMER_SECRET"]);
service.AuthenticateWith(ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN"], ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN_SECRET"]);
string user = paramaters.user.ToString();
user.Replace("#", "");
var tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions()
{
ContributorDetails = true,
Count = 100,
ExcludeReplies = false,
IncludeRts = true,
ScreenName = user
}).ToList();
var tweetsWithLocations = tweets.Where(t => t.Location != null).ToList().OrderBy(t => t.CreatedDate);
return Response.AsJson(tweetsWithLocations.Select(t => new
{
LastTweet = t.TextAsHtml,
Location = t.Location,
Date =
t.CreatedDate.ToShortDateString() + " " +
t.CreatedDate.ToShortTimeString()
})).WithHeaders(new []
{
new { Header = "Access-Control-Allow-Origin", Value="*" }
});
};
}
示例3: GetUserTimeline
// retrieves all post of the user
public static IEnumerable<TwitterStatus> GetUserTimeline(TwitterService service, long userId, bool includeRts, bool excludeReplies)
{
ListTweetsOnUserTimelineOptions options = new ListTweetsOnUserTimelineOptions ();
options.UserId = userId;
options.IncludeRts = includeRts;
options.ExcludeReplies = excludeReplies;
return service.ListTweetsOnUserTimeline (options);
}
示例4: GetFieldValue
public override object GetFieldValue(string fieldValue, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
{
var settings = context.Service.GetItem<TwitterSettings>(TweetCommand.SettingsPath);
TwitterService twitterService = new TwitterService(settings.ConsumerKey, settings.ConsumerSecret);
twitterService.AuthenticateWith(settings.AccessToken, settings.AccessTokenSecret);
return twitterService.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = fieldValue });
}
示例5: GetTweetsStatus
public IEnumerable<TwitterStatus> GetTweetsStatus(string screenName)
{
if (instance.GetTweets == null || instance.LastRefresh < DateTime.UtcNow.AddHours(-2))
{
var service = new TwitterService(ConfigurationManager.AppSettings["TwitterConsumerKey"].ToString(), ConfigurationManager.AppSettings["TwitterConsumerSecret"].ToString());
service.AuthenticateWith(ConfigurationManager.AppSettings["TwitterToken"].ToString(), ConfigurationManager.AppSettings["TwitterTokenSecret"].ToString());
instance.GetTweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 150 }).ToList();
instance.LastRefresh = DateTime.UtcNow;
}
return instance.GetTweets;
}
示例6: TwitterLoad
public void TwitterLoad()
{
var twitterApp = new TwitterService("", "");
twitterApp.AuthenticateWith("", "");
IEnumerable<TwitterStatus> tweets = twitterApp.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = "ACCOUNTNAME", Count = 1, });
if (tweets != null){
foreach (var tweet in tweets)
{
LatestTweet = tweet.Text;
}
}
}
示例7: Index
public ActionResult Index()
{
string consumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"];
string consumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"];
//TwitterService("Consumer Key", "Consumer Secret");
var service = new TwitterService(consumerKey, consumerSecret);
//AuthenticatedWith("Access Token", "AccessTokenSecret");
service.AuthenticateWith("486817944-yhSED5Ysl9QIMHcBtytpxzQizupSftTNGbaxZlEV", "XjLnM06gky1r7pZnLhQCB2uu052qkUatkVqgR7yGvQEne");
//ScreenName="Screen Name", Count=Number of Tweets /www.twitter.com/screenname.
IEnumerable<TwitterStatus> tweetsByHandle = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = "kare11", Count = 5 });
//IEnumerable<TwitterStatus> tweetsByHandle = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = "HFBoysLax", Count = 5 });
TwitterSearchResult tsr = service.Search(new SearchOptions { Q = "Paris", Count = 5 });
IEnumerable<TwitterStatus> tweetsByHashTag = tsr.Statuses;
IEnumerable<TwitterStatus> tweets = tweetsByHandle.Concat(tweetsByHashTag);
ViewBag.Tweets = tweets.OrderByDescending(CreatedDate => CreatedDate);
return View();
}
示例8: ReadTweets
public static IEnumerable<TwitModel> ReadTweets(bool Cached = true)
{
var cache = HttpRuntime.Cache;
if (Cached && cache["ReadTwits"] != null)
{
return (TwitModel[])cache["ReadTwits"];
}
else
{
var service = new TwitterService(ConfigurationManager.AppSettings["TWITTER_CONSUMER_KEY"], ConfigurationManager.AppSettings["TWITTER_CONSUMER_SECRET"]);
service.AuthenticateWith(ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN"], ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN_SECRET"]);
var tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { IncludeRts = true, Count = 2 });
var r = tweets.Select(p => new TwitModel { Text = p.TextAsHtml, Name = p.Author.ScreenName }).ToArray();
cache.Add("ReadTwits", r, null, DateTime.MaxValue, new TimeSpan(ReadTwitCacheTimeOut, 0, 0), CacheItemPriority.Default, null);
return r;
}
}
示例9: Page_Loaded
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (Frame.CanGoBack)
{
((Frame)Window.Current.Content).BackStack.Clear();
}
if (NetworkInterface.GetIsNetworkAvailable())
{
//Obtain keys by registering your app on https://dev.twitter.com/apps
var service = new TwitterService("SEuJKVyiLrpntSmX76mLLK5rV", "2oLc3FgsOC1heh6vyiKlBXDWKnLo2dO9UAgHDxgS6WPnwbh2Rq");
service.AuthenticateWith("197426566-jB7G6TbKGPVHS84rQ2LezVyZp2WJxR5kabaR5sHN", "ntb1049lvRbdX0k5aZkxlWeEvbAZtZm35ekazZnlwBj05");
//ScreenName is the profile name of the twitter user.
service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = "PerumBULOG" }, (ts, rep) =>
{
if (rep.StatusCode == HttpStatusCode.OK)
{
//bind
//this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { tweetList.ItemsSource = ts; } );
}
});
}
else
{
var dialog = new MessageDialog("Please check your internet connestion.").ShowAsync();
}
}
示例10: GetTwitterTweets
public static List<ModelTwitterFeedsDetails> GetTwitterTweets(string ScreenName)
{
ModelTwitterFeeds modelTwitterFeeds = new ModelTwitterFeeds();
List<ModelTwitterFeedsDetails> lstModelTwitterFeedsDetail = new List<ModelTwitterFeedsDetails>();
try
{
/*>>> API Creadentials <<<<////
>> Under Informnation is creating from Personal Account Information API
>> For any change in this credentials Login Account : [email protected]
>> API Name : News Get Application
>> Please don't change any word without permission from following API Admin*/
string _consumerKey = "cvRCCaqLUlM9SyolFwYEQQ2uZ";
string _consumerSecret = "sVvOgCPwuzXo37v4qjAriGbftwEefMC9xNadPQLTsoOkeqiJ8C";
string _accessToken = "65042389-YQ3jLfP1RWu9Q7So9VAj3Rc3J9oMB0Suuv0jlioAN";
string _accessTokenSecret = "yHMVHihkHAaCIOJi2M9WEOq4fpODY1a0hdS92J9OZEJEL";
// API access Data End
var service = new TwitterService(_consumerKey, _consumerSecret);
//var tweets = new ListTweetsOnHomeTimelineOptions();
service.AuthenticateWith(_accessToken, _accessTokenSecret);
IAsyncResult result = service.BeginListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
IEnumerable<TwitterStatus> tweets = service.EndListTweetsOnHomeTimeline(result);
foreach (var tweet in tweets)
{
if (tweets != null)
{
modelTwitterFeeds.FeedId = 0;
modelTwitterFeeds.UserPageId = 0;
modelTwitterFeeds.UserPageTitle = String.Empty;
modelTwitterFeeds.UserScreenName = String.Empty;
modelTwitterFeeds.UserPageLanguage = String.Empty;
modelTwitterFeeds.UserPageFollowers = 0;
modelTwitterFeeds.UserPageCoverImageURL = String.Empty;
modelTwitterFeeds.UserPageLogoImage = String.Empty;
}
var st1 = tweet.Text; //string
var st2 = tweet.Source; //string
var st3 = tweet.TextAsHtml; //string
var st4 = tweet.TextDecoded; //string
var st5 = tweet.RetweetedStatus; //TwitterStatus
var st6 = tweet.RetweetCount; //int
var st7 = tweet.RawSource; //string
var st8 = tweet.Place; //TwitterPlace
var st9 = tweet.Location; //TwitterGeoLocation
var st10 = tweet.Language; //string
var st11 = tweet.IsTruncated; //bool
var st12 = tweet.IsRetweeted; //bool
var st13 = tweet.IsPossiblySensitive; //bool is nullable
var st14 = tweet.IsFavorited; //bool
var st15 = tweet.InReplyToUserId; //long is nullable
var st16 = tweet.InReplyToStatusId; //long is nullable
var st17 = tweet.InReplyToScreenName; //string
var st18 = tweet.IdStr; //string
var st19 = tweet.Id; //long
var st20 = tweet.FavoriteCount; //int
var st21 = tweet.ExtendedEntities; //TwitterExtendedEntities
var st22 = tweet.Entities; //TwitterEntities
var st23 = tweet.CreatedDate; //DateTime
var st24 = tweet.Author; //ITweeter
}
//TwitterAccount user = new TwitterAccount.
//TwitterUser twitterUser =
//>>GET OTHER USER TIMELINE//BeginListTweetsOnHomeTimeline
TwitterService t_service = new TwitterService(_consumerKey, _consumerSecret);
t_service.AuthenticateWith(_accessToken, _accessTokenSecret);
var t_options = new ListTweetsOnHomeTimelineOptions();
t_options.ExcludeReplies = true;
var t_tweets = t_service.ListTweetsOnHomeTimeline(t_options);
//ListTweetsOnSpecifiedUserTimeline
string ScreenNameBBCArabic = "BBCArabic";
string ScreenNameCNNArabic = "cnnarabic";
string ScreenName1 = "garbo_speaks";
var User_OptionInit = new ListTweetsOnUserTimelineOptions { ScreenName = ScreenNameCNNArabic, Count = 200, ExcludeReplies = true };
var User_Tweets = service.ListTweetsOnUserTimeline(User_OptionInit);
string TweetText = String.Empty;
foreach (var tweet in User_Tweets)
{
var userDetail = tweet.User;
if (false)
{
var us1 = tweet.User.ContributorsEnabled; //bool?
var us2 = tweet.User.CreatedDate;
var us3 = tweet.User.Description;
var us4 = tweet.User.FavouritesCount;
var us5 = tweet.User.FollowersCount;
var us6 = tweet.User.FollowRequestSent;
var us7 = tweet.User.FriendsCount;
var us8 = tweet.User.Id;
var us9 = tweet.User.IsDefaultProfile;
var us10 = tweet.User.IsGeoEnabled;
var us11 = tweet.User.IsProfileBackgroundTiled;
var us12 = tweet.User.IsProtected;
var us13 = tweet.User.IsTranslator;
//.........这里部分代码省略.........
示例11: DeserialiseTweetsOnTimeLine
private void DeserialiseTweetsOnTimeLine(int? Items )
{
var service = new Tweet.TwitterService(this.OAuthRequest.consumerKey, this.OAuthRequest.consumerSecret);
service.AuthenticateWith(this.OAuthRequest.accessToken, this.OAuthRequest.accessTokenSecret);
var options = new Tweet.ListTweetsOnUserTimelineOptions();
options.ScreenName = this.username;
options.IncludeRts = true;
if (Items != null) options.Count = Items;
var t = service.ListTweetsOnUserTimeline(options);
foreach (var tweet in t)
{
clsTweet e = new clsTweet(tweet.Id,tweet.Text,tweet.TextAsHtml,"",tweet.CreatedDate,tweet.Author.ScreenName,tweet.Author.ProfileImageUrl);
_entries.Add(e);
}
service = null;
options = null;
}
示例12: appbar_button1_Click
//.........这里部分代码省略.........
}
});
}
});
}
else if (header == "messages")
{
service.ListDirectMessagesReceived(40,
(tweets, response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
DateTime ti = DateTime.Now;
DateTime now = ti.ToUniversalTime();
lists = new List<Tweet>();
foreach (var tweet in tweets)
{
Tweet tv = new Tweet();
TimeSpan tsp = now - tweet.CreatedDate;
tv.id = tweet.Id;
tv.name = tweet.Sender.ScreenName;
tv.thumb_img = tweet.Sender.ProfileImageUrl;
tv.text = tweet.Text + "\n";
if (tsp.Days > 0)
tv.time = tsp.Days + "일 전";
else if (tsp.Hours > 0)
tv.time = tsp.Hours + "시간 전";
else
tv.time = tsp.Minutes + "분 전";
lists.Add(tv);
}
Dispatcher.BeginInvoke(delegate()
{
if (lists.Count > 0)
{
loadtext.Visibility = Visibility.Collapsed;
pgbar.Visibility = Visibility.Collapsed;
listdata3.ItemsSource = lists;
listdata3.Visibility = Visibility.Visible;
}
else
{
pgbar.Visibility = Visibility.Collapsed;
loadtext.Text = "No items";
}
});
}
});
}
else if (header == "my")
{
service.ListTweetsOnUserTimeline(0, 40,
(tweets, response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
DateTime ti = DateTime.Now;
DateTime now = ti.ToUniversalTime();
lists = new List<Tweet>();
foreach (var tweet in tweets)
{
Tweet tv = new Tweet();
TimeSpan tsp = now - tweet.CreatedDate;
tv.id = tweet.Id;
tv.name = tweet.User.ScreenName;
tv.thumb_img = tweet.User.ProfileImageUrl;
tv.text = tweet.Text + "\n";
if (tsp.Days > 0)
tv.time = tsp.Days + "일 전";
else if (tsp.Hours > 0)
tv.time = tsp.Hours + "시간 전";
else
tv.time = tsp.Minutes + "분 전";
lists.Add(tv);
}
Dispatcher.BeginInvoke(delegate()
{
if (lists.Count > 0)
{
loadtext.Visibility = Visibility.Collapsed;
pgbar.Visibility = Visibility.Collapsed;
listdata4.ItemsSource = lists;
listdata4.Visibility = Visibility.Visible;
}
else
{
pgbar.Visibility = Visibility.Collapsed;
loadtext.Text = "No items";
}
});
}
});
}
}
示例13: Load
protected void Load(TwitterResource resource)
{
var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);
switch (resource.Type)
{
case ResourceType.Home:
service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Mentions:
service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Messages:
service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Favorites:
service.ListFavoriteTweets(new ListFavoriteTweetsOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.List:
service.ListTweetsOnList(new ListTweetsOnListOptions
{
IncludeRts = false,
Count = 1,
OwnerScreenName = resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
Slug = resource.Data.Substring(resource.Data.IndexOf('/') + 1)
}, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Search:
service.Search(new SearchOptions { Count = 1, IncludeEntities = true, Q = resource.Data }, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Tweets:
service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 1, ScreenName = resource.Data, IncludeRts = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
}
}
示例14: PostToReader
public static List<string> PostToReader(string _consumerKey, string _consumerSecret, string _accessToken, string _accessTokenSecret, string gUsername, string gPassword, bool chkTweets, bool chkFavorites, bool chkRetweets, bool chkLinks, bool chkNoLinks)
{
List<string> res = new List<string>();
GoogleReader gr = new GoogleReader(gUsername, gPassword);
var serviceReader = new TwitterService(_consumerKey, _consumerSecret);
serviceReader.AuthenticateWith(_accessToken, _accessTokenSecret);
Regex urlfind = new Regex("((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|])", RegexOptions.IgnoreCase);
List<TwitterStatus> mytweets =null;
List<TwitterStatus> favorites=null;
List<TwitterStatus> retweets =null;
if (chkTweets) mytweets = serviceReader.ListTweetsOnUserTimeline(5).ToList();
if (chkFavorites) favorites = serviceReader.ListFavoriteTweets(5).ToList();
if (chkRetweets) retweets = serviceReader.ListRetweetsByMe(5).ToList();
List<TwitterStatus> alltweets = new List<TwitterStatus>();
if (mytweets != null) alltweets.AddRange(mytweets);
if (favorites != null) alltweets.AddRange(favorites);
if (retweets != null) alltweets.AddRange(retweets);
foreach (var tweet in alltweets)
{
if (hassent(tweet.Id.ToString())) { continue; }
Match thematch = urlfind.Match(tweet.Text);
if (thematch.Success)
{
if (chkLinks)
{
string theshorturl = thematch.Groups[1].Value;
string theurl = thematch.Groups[1].Value;
try
{
string longurlxml = c.DownloadString("http://api.unshort.me/?r=" + theurl);
Regex resUrl = new Regex("<resolvedURL>(.*?)</resolvedURL>");
Match resolved = resUrl.Match(longurlxml);
if (resolved.Success)
{
theurl = resolved.Groups[1].Value;
}
}
catch
{
}
string title;
string content = embed(theurl, out title);
gr.post(content, theurl, title, tweet.Text.Replace(theshorturl, "").Trim());
AddID(tweet.Id.ToString(), tweet.Text);
}
}
else if (chkNoLinks)
{
gr.post("", "http://twitter.com/" + tweet.User.ScreenName + "/status/" + tweet.Id, "from twitter", tweet.Text.Trim());
AddID(tweet.Id.ToString(), tweet.Text);
}
res.Add( DateTime.Now.ToShortTimeString() + ": " + tweet.Text);
}
return res;
}
示例15: getTweets
/// <summary>
/// Returns the tweets for ChildCancerNZ
/// </summary>
/// <returns></returns>
public IEnumerable<TwitterStatus> getTweets()
{
List<String> urlOfImages = new List<String>();
var service = new TwitterService(OAuthConsumerKey, OAuthConsumerSecret);
service.AuthenticateWith(OAuthToken, OAuthTokenSecret);
ListTweetsOnHomeTimelineOptions options = new ListTweetsOnHomeTimelineOptions();
IEnumerable<TwitterStatus> tweets =
service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions {ScreenName = "ChildCancerNZ"});
return tweets;
}