public void TestMethod1()
        {
            var file = ConfigurationManager.AppSettings["analyticsKeyFile"];
            var sut = new AnalyticsHelper(file);
            var pv = sut.GetPvAsync().Result;

            Assert.IsTrue(pv > 0);
        }
Exemple #2
0
        static void Main()
        {
            var file = ConfigurationManager.AppSettings["analyticsKeyFile"];
            var helper = new AnalyticsHelper(file);

            var pv = helper.GetPvAsync().Result;
            var message = string.Format("昨日のなか日記のPVは{0}でしたyo http://nakaji.hatenablog.com/ ", pv);
            TwitterHelper.UpdateStatusAsync(message).Wait();
        }
        // GET api/TweetPV
        public async Task<string> Get()
        {
            var file = ConfigurationManager.AppSettings["analyticsKeyFile"];
            var analyticsKeyFile = file.StartsWith("~") ? HttpContext.Current.Server.MapPath(file) : file; // ~で始まっていれば絶対パスに変換
            var helper = new AnalyticsHelper(analyticsKeyFile);
            
            var pv = await helper.GetPvAsync();
            var message = string.Format("昨日のなか日記のPVは{0}でしたyo http://nakaji.hatenablog.com/ ", pv);
            await TwitterHelper.UpdateStatusAsync(message);

            return message;
        }