public List <TweetExtended> getTimeline(TwUser usr) { var tokens = TwitrucHelpers.getTokens(usr); var o = new Twitterizer.TimelineOptions(); o.Count = 60; try { Twitterizer.TwitterResponse <Twitterizer.TwitterStatusCollection> userResponse = Twitterizer.TwitterTimeline.HomeTimeline(tokens, o); if (userResponse.Content != null) { return(userResponse.ResponseObject.Where(st => st != null).Select(st => new TweetExtended(st)).ToList()); } } catch (Exception) { } return(db.TweetSet.Where(t => t.AuthorNick == usr.Nickname).ToArray().Select(t => new TweetExtended(t)).ToList()); }
/// <param name="options">The options.</param> /// <returns>A collection of <see cref="TwitterStatus"/> items.</returns> public static TwitterResponse <TwitterStatusCollection> HomeTimeline(TimelineOptions options) { return(HomeTimeline(null, options)); }
/// <overloads> /// Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web. /// </overloads> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns>A collection of <see cref="TwitterStatus"/> items.</returns> public static TwitterResponse <TwitterStatusCollection> HomeTimeline(OAuthTokens tokens, TimelineOptions options) { Commands.HomeTimelineCommand command = new Commands.HomeTimelineCommand(tokens, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Returns the 20 most recent retweets posted by the authenticating user's friends. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns>A <see cref="TwitterStatusCollection"/> instance.</returns> public static TwitterResponse <TwitterStatusCollection> RetweetedToMe(OAuthTokens tokens, TimelineOptions options) { return(CommandPerformer.PerformAction( new Commands.RetweetedToMeCommand(tokens, options))); }
/// <summary> /// Returns the 20 most recent retweets posted by the authenticating user's friends. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options. Leave null for defaults.</param> /// <returns>A <see cref="TwitterStatusCollection"/> instance.</returns> public static async Task <TwitterResponse <TwitterStatusCollection> > RetweetedToMeAsync(OAuthTokens tokens, TimelineOptions options = null) { return(await Core.CommandPerformer.PerformAction(new Commands.RetweetedToMeCommand(tokens, options))); }
public List<TweetExtended> getTimeline(TwUser usr) { var tokens = TwitrucHelpers.getTokens(usr); var o = new Twitterizer.TimelineOptions(); o.Count = 60; try { Twitterizer.TwitterResponse<Twitterizer.TwitterStatusCollection> userResponse = Twitterizer.TwitterTimeline.HomeTimeline(tokens, o); if (userResponse.Content != null) { return userResponse.ResponseObject.Where(st => st != null).Select(st => new TweetExtended(st)).ToList(); } } catch (Exception) { } return db.TweetSet.Where(t => t.AuthorNick == usr.Nickname).ToArray().Select(t => new TweetExtended(t)).ToList(); }
/// <summary> /// Returns the 20 most recent mentions (status containing @username) for the authenticating user. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <param name="timeout">The timeout.</param> /// <param name="function">The function.</param> /// <returns></returns> public static IAsyncResult Mentions(OAuthTokens tokens, TimelineOptions options, TimeSpan timeout, Action <TwitterAsyncResponse <TwitterStatusCollection> > function) { return(AsyncUtility.ExecuteAsyncMethod(tokens, options, timeout, TwitterTimeline.Mentions, function)); }
/// <summary> /// The recent modifications for a course /// </summary> /// <param name="account">With the account data to use on the query</param> private void GetRecentTweetsForAccount(Account account) { TimelineManager.ReportProgress(new Status(account.ID, "Loading account...")); // Load the cached data LinkedList <Frame> frames = TimelineManager.GetCachedFramesFromDB(account); foreach (Frame frame in frames) { this.AddFrame(frame); } frames.Clear(); BackgroundWorker bgWorker = new BackgroundWorker(); this.workers.AddLast(bgWorker); bgWorker.WorkerReportsProgress = true; bgWorker.WorkerSupportsCancellation = true; bgWorker.DoWork += new DoWorkEventHandler(delegate(object wsender, DoWorkEventArgs args) { // Load the remote data try { Twitterizer.OAuthTokens authToken = TwitterTimeline.getTwitterAuthToken(account); Twitterizer.TimelineOptions options = new Twitterizer.TimelineOptions(); String sinceStatusId = account.getOption("SinceStatusId"); if (sinceStatusId != null) { options.SinceStatusId = Convert.ToDecimal(sinceStatusId); } else { options.Count = 10; } Twitterizer.TwitterResponse <TwitterStatusCollection> timeline = Twitterizer.TwitterTimeline.HomeTimeline(authToken, options); if (sinceStatusId != null && timeline.Result == Twitterizer.RequestResult.Success && timeline.ResponseObject.Count < 10) { options = new Twitterizer.TimelineOptions(); options.Count = 10; timeline = Twitterizer.TwitterTimeline.HomeTimeline(authToken, options); } if (timeline.Result == Twitterizer.RequestResult.Success) { frames.Clear(); Frame frame; foreach (Twitterizer.TwitterStatus status in timeline.ResponseObject) { frame = new Frame(account, "[" + account.Name + "] @" + status.User.ScreenName, status.Text, status.CreatedDate, ((status.User.Website != null) ? new Uri(status.User.Website) : null), Convert.ToInt64(status.Id)); frame.ImageUrl = new Uri(status.User.ProfileImageLocation); frames.AddLast(frame); } if (timeline.ResponseObject[0] != null) { sinceStatusId = Convert.ToString(timeline.ResponseObject[0].Id); } args.Result = Convert.ToString(sinceStatusId); } } catch { //MessageBox.Show(ex.Message+ ex.StackTrace); } }); bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate(object wsender, RunWorkerCompletedEventArgs args) { TimelineManager.CacheFramesOnDB(account, frames); int totalFramesAdded = 0; foreach (Frame frame in frames) { if (TimelineManager.AddFrame(frame)) { totalFramesAdded++; } } TimelineManager.RegisterEvent(account); if (!args.Cancelled && args.Error == null) { String sinceStatusId = args.Result as String; account.setOption("SinceStatusId", sinceStatusId); } account.LastUpdate = DateTime.Now; ConfigurationManager.UpdateUserAccount(account); TimelineManager.ReportProgress(new Status(account.ID, totalFramesAdded + " new twitts loaded.")); this.workers.Remove(bgWorker); }); bgWorker.RunWorkerAsync(account); }