コード例 #1
0
        public static async Task <TwitterApiResponse <bool> > IsNameAvailable(string screenName)
        {
            TwitterApiResponse <bool> response = new TwitterApiResponse <bool>();

            response.Content = true;

            try
            {
                var ctx = new TwitterContext(new SingleUserAuthorizer
                {
                    CredentialStore = GetCredentials()
                });
                var query = await(
                    from search in ctx.User
                    where search.Type == UserType.Show && search.ScreenName == screenName
                    select search).SingleOrDefaultAsync();

                if (query != null)
                {
                    response.Content = false;
                    var name       = query.ScreenNameResponse;
                    var lastStatus = query.Status == null ? "No Status" : query.Status.Text;
                }
            }
            catch (TwitterQueryException ex)
            {
                response.Content = ex.StatusCode == System.Net.HttpStatusCode.NotFound ? true : false;
                response.Error   = CreateError(ex);
            }

            return(response);
        }
コード例 #2
0
        // GET: Monitoring
        public async Task <ActionResult> Index()
        {
            var model = new MonitoringViewModel();
            TwitterApiResponse <Dictionary <string, RateLimit> > response = await TwitterApiManager.GetRateLimits();

            model.RateLimits = response.Content;
            try
            {
                model.LastNameChecks = await NameCheckDataService.GetCollectionAsync();

                model.LastNameCheckBatches = await NameCheckBatchDataService.GetCollectionAsync();
            }
            catch (Exception ex)
            {
                model.Error = ex;
            }

            model.Configuration = ReadConfiguration();
            return(View(model));
        }