Ejemplo n.º 1
0
        public async Task <AccountTwitter> GetAuthorizedAccount(string userToken)
        {
            var queryParams = new Dictionary <string, string>();

            queryParams.Add("format", "json");
            queryParams.Add("include_email", "true");
            queryParams.Add("include_entities", "false");

            var headers = new Dictionary <string, string>();

            headers.Add("Authorization", "OAuth " + userToken);

            AccountTwitter response = await this.Client.GetRequestAsync <AccountTwitter>("1.1/account/verify_credentials.json", headers, queryParams, CancellationToken.None);

            return(response);
        }
        public override async Task <IEnumerable <ConnectorEntity> > GetEntities(string jobId)
        {
            List <ConnectorEntity> entities = new List <ConnectorEntity>();

            var PageJobMappingTable = azureTableProvider.GetAzureTableReference(Settings.PageJobMappingTableName);
            Expression <Func <PageJobEntity, bool> > filter = (entity => entity.RowKey == $"{jobId}");
            List <PageJobEntity> pageJobEntityList          = await azureTableProvider.QueryEntitiesAsync <PageJobEntity>(PageJobMappingTable, filter);

            PageJobEntity pageJobEntity = pageJobEntityList?[0];

            string         userToken      = twitterAuthProvider.GetUserTokenForjobId(pageJobEntity);
            AccountTwitter AccountTwitter = await twitterAuthProvider.GetAuthorizedAccount(userToken);

            entities.Add(new ConnectorEntity {
                Id   = AccountTwitter.Id,
                Name = AccountTwitter.Name
            });

            return(entities);
        }