Created
November 5, 2010 00:36
-
-
Save rchern/663462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Stacky; | |
| namespace SOAPIPlayground { | |
| class Program { | |
| static void Main(string[] args) { | |
| var siteClient = new StackyClient("1.0", "", Sites.StackOverflow, new UrlClient(), new JsonProtocol()); | |
| var userID = 21441; | |
| var answers = siteClient.GetUsersAnswers(userID, QuestionsByUserSort.Activity, SortDirection.Descending, 1, 100, false, true); | |
| int totalAnswers = answers.TotalItems; | |
| int curPage = 1; | |
| string term = "cascade"; | |
| Console.WriteLine("Searching " + answers.TotalItems + " answers for " + term + "."); | |
| while (curPage < totalAnswers / (1.0 * answers.PageSize) + 1) { | |
| Console.WriteLine("Searching page " + answers.CurrentPage); | |
| foreach (var answer in answers) { | |
| foreach (var comment in answer.Comments) { | |
| if (comment.Body.Contains(term)) { | |
| Console.WriteLine(comment.Body); | |
| return; | |
| } | |
| } | |
| } | |
| curPage++; | |
| answers = siteClient.GetUsersAnswers(userID, QuestionsByUserSort.Activity, SortDirection.Descending, curPage, 100, false, true); | |
| } | |
| var mentions = siteClient.GetUserMentions(userID, UserMentionSort.Creation, SortDirection.Descending, 1, 100); | |
| int totalMentions = mentions.TotalItems; | |
| curPage = 1; | |
| Console.WriteLine("Searching " + totalMentions + " mentions for " + term + "."); | |
| while (curPage < totalMentions / (1.0 * mentions.PageSize) + 1) { | |
| Console.WriteLine("Searching page " + mentions.CurrentPage); | |
| foreach (var mention in mentions) { | |
| if (mention.Body.Contains(term)) { | |
| Console.WriteLine(mention.Body); | |
| return; | |
| } | |
| } | |
| curPage++; | |
| mentions = siteClient.GetUserMentions(userID, UserMentionSort.Creation, SortDirection.Descending, curPage, 100); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment