public Dictionary <int, String> getTitles() { Dictionary <int, String> titles = new Dictionary <int, String>(); var client = new StacManClient(key: "ZooTQP9hfBOle)91FBc)uQ((", version: "2.1"); DateTime today = DateTime.Today; today.AddDays(-1); DateTime today2 = DateTime.Today; //today2.AddDays(-1); var dateTime = new DateTime(); //dateTime = dateTime.AddDays(-1); var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var unixDateTime = (dateTime.ToUniversalTime() - epoch).TotalSeconds; var response = client.Questions.GetAll("stackoverflow", page: 1, pagesize: 50, //fromdate: today, //todate: today2, sort: StackExchange.StacMan.Questions.AllSort.Creation, order: Order.Desc).Result; foreach (var question in response.Data.Items) { titles.Add(question.QuestionId, question.Title); //Console.WriteLine(question.Title); } return(titles); }
/// <summary> /// Stack data source implementation /// </summary> public void GetStackResults() { var client = new StacManClient(key: ConfigurationManager.AppSettings["stackAppKey"], version: "2.1"); var response = client.Questions.GetAll("stackoverflow", page: 1, pagesize: 10, sort: StackExchange.StacMan.Questions.AllSort.Creation, order: Order.Desc, filter: "withbody", tagged: ConfigurationManager.AppSettings["stackTags"]).Result; foreach (var question in response.Data.Items) { Posts res = new Posts(); res.Name = question.Owner.DisplayName; res.PostText = question.Body; res.Category = string.Join(", ", question.Tags); //If tags are null, place in General category if (res.Category == "" || res.Category == null) { res.Category = "General"; } res.Source = "Stack Overflow"; res.GUID = question.QuestionId.ToString(); PostResults.Add(res); } }
public void BasicTestWithManager() { var client = new StacManClient(); client.UserAgent = GetType().Name; List <string> urls = new List <string>(); client.SetUrlManager(x => { lock (urls) urls.Add(x); System.Console.WriteLine("Querying: " + x); return(x); }); var sites = client.Sites.GetAll(pagesize: 50).Result; Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", sites.ApiUrl); Assert.AreEqual(50, sites.Data.Items.Count()); Assert.IsTrue(sites.Data.HasMore); lock (urls) { Assert.AreEqual(1, urls.Count); Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", urls[0]); } }
/// <summary> /// Initializes a new instance of the /// <see cref="DevAchievements.Infrastructure.AchievementProviders.StackExchange.StackExchangeAchievementProvider"/> class. /// </summary> public StackExchangeAchievementProvider() : base(new AchievementIssuer("StackOverflow") { LogoUrl = "http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo-med.png" }) { m_client = new StacManClient(); }
public void BasicTestNoManager() { var client = new StacManClient(); var sites = client.Sites.GetAll(pagesize: 50).Result; Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", sites.ApiUrl); Assert.AreEqual(50, sites.Data.Items.Count()); Assert.IsTrue(sites.Data.HasMore); }
public async Task <IList <ExceptionHandlingWebAPI.Models.Tag> > GetTagsAsync() { var client = new StacManClient(version: "2.2"); var response = await client.Tags.GetAll("stackoverflow"); var tags = response.Data.Items.ToList(); return(Mapper.Map <IList <ExceptionHandlingWebAPI.Models.Tag> >(tags)); }
private async Task GetTagsAsync() { StacManClient client = new StacManClient("9Cb1HN**U)0Eq1faZzkIAQ((", "2.0"); for (int i = 1; i < 11; i++) { TagCollection.AddRange((await client.Tags.GetAll("stackoverflow", null, i, 100)).Data.Items); } AllUseCount = TagCollection.Sum(x => x.Count); }
private static async Task <StacManResponse <Question> > GetQuestions(TraceWriter log) { var stackexchangekey = Util.GetSetting("StackExchangeKey"); log.Info($"StackOverAzure function executed at: {DateTime.Now}"); var client = new StacManClient(key: stackexchangekey, version: "2.1"); var response = await client.Questions.GetAll("stackoverflow", tagged : Util.GetSetting("tags"), page : 1, pagesize : 50, sort : StackExchange.StacMan.Questions.AllSort.Creation, order : Order.Desc); return(response); }
public Question getQuestionById(int?id) { var client = new StacManClient(key: "ZooTQP9hfBOle)91FBc)uQ((", version: "2.1"); int[] idss = new int[1]; idss[0] = (int)id; var response = client.Questions.GetByIds("stackoverflow", ids: idss, filter: "withbody").Result; //var response1 = client.Posts.GetByIds("stackoverflow", ids: idss).Result; if (response.Data.Items == null) { return(null); } return(response.Data.Items[0]); }
public static void AddData(IDocumentStore store, int pages) { string stackAppsKey = Environment.GetEnvironmentVariable("stackAppsKey"); int page = 1; bool hasMore = true; while (hasMore) { var client = new StacManClient(key: stackAppsKey, version: "2.2"); var response = client.Questions.GetAll("stackoverflow", page: page, pagesize: 100, sort: StackExchange.StacMan.Questions.AllSort.Activity, order: Order.Asc, tagged: "python", //filter: "!9Z(-wwYGT", // question with body //filter: "!9Z(-wwK0y", //question with body and body_markdown filter: "!LVBj29mB6Y(88vxKX2ObLu" //with comments and answers bodies ).Result; foreach (var question in response.Data.Items) { System.Console.WriteLine(question.Title); } using (BulkInsertOperation bulkInsert = store.BulkInsert()) { foreach (var question in response.Data.Items) { bulkInsert.Store(question); } } if (response.Data.Backoff.HasValue) { Thread.Sleep(response.Data.Backoff.Value * 2000); } Thread.Sleep(1000); hasMore = response.Data.HasMore && page < pages; page++; } }
public void BasicTestWithManager() { var client = new StacManClient(); client.UserAgent = GetType().Name; List<string> urls = new List<string>(); client.SetUrlManager(x => { lock (urls) urls.Add(x); System.Console.WriteLine("Querying: " + x); return x; }); var sites = client.Sites.GetAll(pagesize: 50).Result; Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", sites.ApiUrl); Assert.AreEqual(50, sites.Data.Items.Count()); Assert.IsTrue(sites.Data.HasMore); lock (urls) { Assert.AreEqual(1, urls.Count); Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", urls[0]); } }
public ActionResult Index() { var test = new StacManClient(null, "2.1"); return(View()); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; string search = activity.Text; var client = new StacManClient(key: "", version: "2.1"); if (search.Split(' ')[0] == "Yes") { search = search.Split(' ')[2]; } int page = int.TryParse(search, out page) ? page : 1; var carouselReply = context.MakeMessage(); carouselReply.AttachmentLayout = AttachmentLayoutTypes.Carousel; var cardReply = context.MakeMessage(); if (search != "No") { var response = await client.Search.GetMatches("stackoverflow", page : page, pagesize : 10, order : Order.Desc, sort : StackExchange.StacMan.Questions.SearchSort.Votes, intitle : search); if (response.Data.Items.GetLength(0) > 0) { foreach (var question in response.Data.Items) { string url = "https://api.thumbnail.ws/api/" + API_KEY_THUMBNAIL + "/thumbnail/get" + "?url=" + question.Link + "&width=" + 640; carouselReply.Attachments.Add(GetHeroCard(question.Title, "Score" + question.Score, "Owner" + question.Owner, new CardImage(url: url), new CardAction(ActionTypes.OpenUrl, "Read more", value: question.Link))); } cardReply.Attachments.Add(GetAnimationCard("More questions?", "Do you want more result?", HACKING_TIME_GIF, new CardAction(ActionTypes.ImBack, "Yes", value: "Yes " + "page " + (++page).ToString()), new CardAction(ActionTypes.ImBack, "No", value: "No"))); // return our reply to the user await context.PostAsync(carouselReply); await context.PostAsync(cardReply); } else { cardReply.Attachments.Add(GetAnimationCard("ERROR!", "There aren't result.", ERROR_GIF)); // return our reply to the user await context.PostAsync(cardReply); } } else { cardReply.Attachments.Add(GetAnimationCard("Perfect!", "You've found the solution!", COMMODORE_SOLUTION)); // return our reply to the user await context.PostAsync(cardReply); } context.Wait(MessageReceivedAsync); }
public StackExchangeSearch() { _client = new StacManClient(ConfigurationManager.AppSettings["APIKey"], ConfigurationManager.AppSettings["APIVersion"]); }