public void test_twitter_retweent_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable <TwitterObject> twittes = result.RetweetsOfMeUrl("count=20"); Assert.IsTrue(twittes.Any()); }
public void test_twitter_home_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable <TwitterObject> twittes = result.GetHomeTimeLine("count=20&exclude_replies=true"); Assert.IsTrue(twittes.Any()); }
public void test_twitter_mention_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable <TwitterObject> twittes = result.GetMetionsUrl("count=20&since_id=14927799"); Assert.IsTrue(twittes.Any()); }
public void test_twitter_user_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable <TwitterObject> twitterMessage = result.GetUserTimeLine("screen_name=jsucupira&count=20"); Assert.IsTrue(twitterMessage.Any()); }
public async Task SetFollowersAsync(long userId) { var follower = await TwitterUtil.GetUserFollowersAsync(this.account.TokensData, userId, this.cursor); this.userId = userId; this.cursor = follower.NextCursor; SetUserList(follower.ToList()); this.isLoading = false; }
public async Task SetUserStatusesAsync(long userId) { var timeLine = await TwitterUtil.GetUserTweetAsync(this.account.TokensData, userId, this.maxId); if (timeLine.Count < 1) { return; } this.maxId = timeLine[timeLine.Count - 1].Id - 1; this.userId = userId; SetStatuses(timeLine); this.isLoading = false; }
TryGetUserValueDictionary ( String sScreenName, RequestStatistics oRequestStatistics, Boolean bIgnoreWebAndJsonExceptions, out Dictionary <String, Object> oUserValueDictionary ) { Debug.Assert(!String.IsNullOrEmpty(sScreenName)); Debug.Assert(oRequestStatistics != null); AssertValid(); oUserValueDictionary = null; String sUrl = String.Format( "{0}users/show.json?screen_name={1}&{2}" , TwitterApiUrls.Rest, TwitterUtil.EncodeUrlParameter(sScreenName), TwitterApiUrlParameters.IncludeEntities ); ReportProgress(String.Format( "Getting information about \"{0}\"." , sScreenName )); try { oUserValueDictionary = (Dictionary <String, Object>) (new JavaScriptSerializer()).DeserializeObject( GetTwitterResponseAsString(sUrl, oRequestStatistics)); return(true); } catch (Exception oException) { if (!HttpSocialNetworkUtil.ExceptionIsWebOrJson(oException) || !bIgnoreWebAndJsonExceptions) { throw oException; } return(false); } }
public async Task SetTalkDmAsync(string screenName) { var talk = await TwitterUtil.GetTalkDmAsync(this.account.TokensData, screenName, this.maxId); if (talk.Count < 1) { return; } this.maxId = talk[talk.Count - 1].Id - 1; this.target = screenName; SetTalkDm(talk); this.isLoading = false; }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { this.timeLineViewer.Initialize(this.account, TimeLineMode.Talk); this.talk = await TwitterUtil.GetTalkAsync(this.account.TokensData, this.target); this.timeLineViewer.SetStatuses(this.talk); } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); } this.Activate(); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { this.talkDmViewer.Initialize(this, this.account); List <DirectMessage> talk = await TwitterUtil.GetTalkDmAsync(this.account.TokensData, this.target); this.talkDmViewer.SetTalkDm(talk); await this.talkDmViewer.SetTalkDmAsync(this.target); } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); } this.Activate(); }
BeforeGetNetwork() { AssertValid(); // TwitterAccessToken caches the access token it reads from disk. Make // sure the latest access token is read. TwitterAccessToken oTwitterAccessToken = new TwitterAccessToken(); // A network should never be requested if the access token hasn't been // saved yet. String sToken, sSecret; if (!oTwitterAccessToken.TryLoad(out sToken, out sSecret)) { throw new Exception("Twitter access token not set."); } m_oTwitterUtil = new TwitterUtil(sToken, sSecret, HttpNetworkAnalyzerBase.UserAgent, HttpNetworkAnalyzerBase.HttpWebRequestTimeoutMs); }
EnumerateFriendOrFollowerIDs ( String sScreenName, Boolean bEnumerateFriendIDs, Int32 iMaximumPeoplePerRequest, RequestStatistics oRequestStatistics ) { Debug.Assert(!String.IsNullOrEmpty(sScreenName)); Debug.Assert(iMaximumPeoplePerRequest > 0); Debug.Assert(oRequestStatistics != null); AssertValid(); String sUrl = String.Format( "{0}{1}.json?screen_name={2}" , TwitterApiUrls.Rest, bEnumerateFriendIDs ? "friends/ids" : "followers/ids", TwitterUtil.EncodeUrlParameter(sScreenName) ); // The JSON looped through here has an "ids" name whose value is an // array of integer IDs. foreach (Object oUserIDAsObject in EnumerateJsonValues( sUrl, "ids", iMaximumPeoplePerRequest, true, oRequestStatistics)) { String sUserID; if (TwitterJsonUtil.TryConvertJsonValueToString( oUserIDAsObject, out sUserID)) { yield return(sUserID); } } }
ExceptionToMessage ( Exception oException ) { Debug.Assert(oException != null); AssertValid(); String sMessage = null; const String TimeoutMessage = "The Twitter Web service didn't respond."; const String RefusedMessage = "The Twitter Web service refused to provide the requested" + " information." ; if (oException is WebException) { WebException oWebException = (WebException)oException; if (TwitterUtil.WebExceptionIsDueToRateLimit(oWebException)) { // Note that this shouldn't actually occur, because // this.GetTwitterResponseAsString() pauses and retries when // Twitter rate limits kick in. This "if" clause is included // in case Twitter misbehaves, or if the pause-retry code is // ever removed from GetTwitterResponseAsString(). sMessage = String.Format( RefusedMessage + " A likely cause is that you have made too many Twitter" + " requests in the last 15 minutes. (Twitter" + " limits information requests to prevent its service" + " from being attacked. Click the '{0}' link for" + " details.)" , TwitterRateLimitsControl.RateLimitingLinkText ); } else if (oWebException.Response is HttpWebResponse) { HttpWebResponse oHttpWebResponse = (HttpWebResponse)oWebException.Response; switch (oHttpWebResponse.StatusCode) { case HttpStatusCode.Unauthorized: // HTTP 401. sMessage = RefusedMessage + " The stated reason was \"unauthorized.\""; break; case HttpStatusCode.RequestTimeout: // HTTP 408. sMessage = TimeoutMessage; break; case HttpStatusCode.Forbidden: // HTTP 403. sMessage = RefusedMessage + " The stated reason was \"forbidden.\""; break; default: break; } } else { switch (oWebException.Status) { case WebExceptionStatus.Timeout: sMessage = TimeoutMessage; break; default: break; } } } if (sMessage == null) { sMessage = ExceptionUtil.GetMessageTrace(oException); } return(sMessage); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { User user = null; try { if (string.IsNullOrEmpty(this.targetScreenName)) { user = await TwitterUtil.GetUserAsync(this.account.TokensData, this.targetId); } else { user = await TwitterUtil.GetUserAsync(this.account.TokensData, this.targetScreenName); } } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); this.Close(); return; } if (user == null) { this.Close(); return; } UserInfoItem item = new UserInfoItem(this.account.TokensData, user); this.userInfo = item; this.DataContext = this.userInfo; try { this.timeLineViewer_Tweet.Initialize(this, this.account, TimeLineMode.UserTweet); await this.timeLineViewer_Tweet.SetUserStatusesAsync(this.userInfo.Id); this.userListViewer_Follow.Initialize(this, this.account, UserListMode.Follow); await this.userListViewer_Follow.SetFollowsAsync(this.userInfo.Id); this.userListViewer_Follower.Initialize(this, this.account, UserListMode.Follower); await this.userListViewer_Follower.SetFollowersAsync(this.userInfo.Id); } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); } this.title = new TitleTextItem(string.Format("User Information - @{0}", user.ScreenName)); this.textBlock_Title.DataContext = this.title; this.Activate(); }
public void test_twitter_user_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable<TwitterObject> twitterMessage = result.GetUserTimeLine("screen_name=jsucupira&count=20"); Assert.IsTrue(twitterMessage.Any()); }
public void test_twitter_retweent_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable<TwitterObject> twittes = result.RetweetsOfMeUrl("count=20"); Assert.IsTrue(twittes.Any()); }
public void test_twitter_mention_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable<TwitterObject> twittes = result.GetMetionsUrl("count=20&since_id=14927799"); Assert.IsTrue(twittes.Any()); }
public void test_twitter_home_timeline() { TwitterUtil result = new TwitterUtil(_consumerKey, _consumerSecret, _token, _tokenSecret); IEnumerable<TwitterObject> twittes = result.GetHomeTimeLine("count=20&exclude_replies=true"); Assert.IsTrue(twittes.Any()); }