private void TwitterRequest_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(e.Error.Message); } else { this.FeatureSets.Remove(twitterSet); TwitterResult twResult = TwitterResult.Deserialize(e.Result); twitterSet = new GeoFeatureCollection("title,photoUrl,authorUri,content", "Title,Photo,Author,Content", "title", "Tweets"); if (twResult != null) { foreach (TweetItem item in twResult.items) { Graphic graphic = new Graphic(); graphic.Geometry = (new MapPoint(item.geoLocation.x, item.geoLocation.y, new SpatialReference(4326))).GeographicToWebMercator(); graphic.Attributes.Add("title", item.author.authorName); graphic.Attributes.Add("photoUrl", item.authorLinks[1].linkUrl); graphic.Attributes.Add("authorUri", item.author.authorUri); graphic.Attributes.Add("content", item.content); graphic.Symbol = twitterSymbol; graphic.MapTip = twitterTipTemplate; graphicsLayer.Graphics.Add(graphic); twitterSet.Add(graphic); } this.FeatureSets.Add(twitterSet); this.ToggleWidgetContent(1); } } this.IsBusy = false; }
public TwitterPageIteratorTests() { _firstPage = new TwitterResult <long>(null) { Model = 42 }; _secondPage = new TwitterResult <long>(null) { Model = 43 }; _getNextPage = A.Fake <Func <string, Task <ITwitterResult <long> > > >(); _extractNextCursor = A.Fake <Func <ITwitterResult <long>, string> >(); _isLastPage = A.Fake <Func <ITwitterResult <long>, bool> >(); A.CallTo(() => _getNextPage(null)).Returns(_firstPage); A.CallTo(() => _extractNextCursor(_firstPage)).Returns("cursor_for_page_2"); A.CallTo(() => _extractNextCursor(_secondPage)).Returns("cursor_for_page_3"); A.CallTo(() => _isLastPage(_firstPage)).Returns(false); A.CallTo(() => _isLastPage(_secondPage)).Returns(true); A.CallTo(() => _getNextPage("cursor_for_page_2")).Returns(_secondPage); }
private IEnumerable<Tweet> GotTweets(TwitterResult result) { if (result.RateLimitStatus != null) UpdateLimit(result.RateLimitStatus); if (result.SkippedDueToRateLimiting || result.IsNetworkError || result.IsServiceError || result.IsTwitterError) return new Tweet[] {}; return result. AsStatuses(). Select(twitterStatus => _tweetFactory(twitterStatus)); }
public void Execute(JobExecutionContext context) { var reminderService = context.Get("ReminderService") as ReminderService; var account = context.Get("Account") as Account; DateTime zmanSunset = SchedulerHelper.GetZman(DateTime.UtcNow, reminderService.Location, reminderService.ZmanName) .ToLocalTime(); TwitterResult twitter = FluentTwitter.CreateRequest() .AuthenticateAs(account.UserName, account.Password) .Statuses().Update( string.Format( reminderService.JobOptions["Message"], zmanSunset.ToShortTimeString()) ) .AsJson().Request(); }
public Task <ITwitterResult <IUserDTO[]> > GetUsers(IGetUsersParameters parameters, ITwitterRequest request) { if (parameters.Users.Length == 0) { ITwitterResult <IUserDTO[]> result = new TwitterResult <IUserDTO[]>(null) { Request = null, Response = null, DataTransferObject = new IUserDTO[0] }; return(Task.FromResult(result)); } var query = _userQueryGenerator.GetUsersQuery(parameters); request.Query.Url = query; request.Query.HttpMethod = HttpMethod.GET; return(_twitterAccessor.ExecuteRequest <IUserDTO[]>(request)); }
public static bool ok(this TwitterResult result) { return(result.ResponseHttpStatusDescription == "OK"); }
public static void ValidateResponse(TwitterResult response) { if (response.IsTwitterError) throw new System.ApplicationException(response.ResponseHttpStatusDescription); }