Beispiel #1
0
        public IActionResult AddTwitterAccount(long userId, long groupId, string requestToken, string requestSecret, string requestVerifier, bool follow)
        {
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
            var dbr   = new DatabaseRepository(_logger, _appEnv);
            var OAuth = new oAuthTwitter(_appSettings.twitterConsumerKey,
                                         _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl)
            {
                AccessToken       = requestToken,
                AccessTokenSecret = requestVerifier
            };

            OAuth.GetTwitterAccessToken(requestToken, requestVerifier);
            var output = TwitterRepository.AddTwitterAccount(userId, groupId, follow, dbr, OAuth, _logger, _redisCache, _appSettings);

            if (output.Contains("Twitter account already added by you") || output.Contains("This Account is added by other user") || output.Contains("Issue while fetching twitter userId") || output.Contains("Your Twitter profile is not Authorized to add") || output.Contains("Error while Adding Account"))
            {
                return(BadRequest(output));
            }

            return(Ok(output));
        }