예제 #1
0
        private static async Task <int> Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var    _client     = new PocketClient(_config.PocketConsumerKey, callbackUri: _config.PocketRedirectUri);
            string requestCode = await _client.GetRequestCode();

            Console.WriteLine(_client.GenerateRegistrationUri(requestCode).ToString());
            Console.WriteLine("Press enter after authorizing app...");
            Console.ReadLine();
            PocketUser pocketUser = await _client.GetUser(requestCode);

            IUserService userService = UserService.BuildUserService(_config.StorageConnectionString);

            Console.WriteLine("Input your kindle email:");
            var kindleEmail = Console.ReadLine();

            var user = new User()
            {
                AccessCode         = pocketUser.Code,
                PocketUsername     = pocketUser.Username,
                KindleEmail        = kindleEmail,
                LastProcessingDate = DateTime.UtcNow
            };

            await userService.AddUserAsync(user);

            Console.WriteLine("Bye World!");
            Console.ReadLine();

            return(0);
        }
예제 #2
0
        public static async System.Threading.Tasks.Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            ExecutionContext context)
        {
            Config _config = new ConfigBuilder(context.FunctionAppDirectory).Build();

            var    _client     = new PocketClient(_config.PocketConsumerKey, callbackUri: _config.PocketRedirectUri, isMobileClient: false);
            string requestCode = await _client.GetRequestCode();

            var result = new
            {
                RequestCode      = requestCode,
                RegistrationLink = _client.GenerateRegistrationUri(requestCode)
            };

            return(new OkObjectResult(JsonConvert.SerializeObject(result)));
        }