예제 #1
0
        private void LoadTwitterLogin(TwitterCredentials twitterCreds)
        {
            _twitterHttpClient = new TwitterHttpClient(twitterCreds);
            _loginUser         = _twitterHttpClient.GetAuthenticatedUser();
            if (_loginUser == null)
            {
                WindowTitle = SelectedUserModelIsNullMessage =
                    $"Login user {twitterCreds.ScreenName} not authenticated";
                GroupModelList    = new List <GroupModel>();
                SelectedUserModel = null;
                return;
            }

            _selectedTwitterLogin       = twitterCreds.ScreenName;
            _logingGoupSettingsFileName = $"{twitterCreds.ScreenName}_GroupSettings.json";

            List <Group> groupList      = LoadGroupsFromFile();
            var          groupModelList =
                groupList.Select(x =>
                                 new GroupModel(x.Name, GetGroupImagePath(x.Name))
            {
                GroupScreenNamelList = x.ScreenNameList
            })
                .ToList();

            RefreshFriends(groupModelList);
            WindowTitle = $"Login: {_loginUser.Name} (@{_loginUser.ScreenName})";
            SelectedUserModelIsNullMessage = "Click on a user on the left";
            SelectedUserModel = null;
        }
예제 #2
0
        public Task <HttpResponseMessage> GetLocationBasedConnection(string location)
        {
            if (_httpClient != null)
            {
                throw new NotSupportedException("Multiple connections with one instance of TwitterConnector is not allowed");
            }

            TwitterQueryCollection collection = new TwitterQueryCollection();

            //{southwest}long,lat,{northeast}long,lat
            //The polygon which covers the whole world
            //collection.Add("locations", "-165.0,-75.0,165.0,75.0");
            collection.Add("locations", location);

            _httpClient         = new TwitterHttpClient(_creds, _signatureEntity, collection);
            _httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);

            var filterContent = new StringContent(collection.ToString());

            filterContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
            var filterRequest = new HttpRequestMessage(HttpMethod.Post, filterEndpointUri);

            filterRequest.Content = filterContent;

            return(_httpClient.SendAsync(filterRequest, HttpCompletionOption.ResponseHeadersRead));
        }
예제 #3
0
 public MainViewModel()
 {
     _twitterHttpClient = new TwitterHttpClient(App.TwitterCreds);
     RefreshCommand     = new DelegateCommand(ExecuteRefreshCommand);
     OpenUrlCommand     = new DelegateCommand <string>(ExecuteOpenUrlCommand);
     RefreshUserTweetsRetweetsCommand = new DelegateCommand(ExecuteRefreshUserTweetsRetweetsCommand);
     _groupNameImageChoiceDic         = new Dictionary <string, GroupImageChoice>();
     _lastUsedGroupImageChoice        = GroupImageChoice.None;
 }
예제 #4
0
        public Task <HttpResponseMessage> GetSampleFirehoseConnection()
        {
            if (_httpClient != null)
            {
                throw new NotSupportedException("Multiple connections with one instance of TwitterConnector is not allowed");
            }

            _httpClient         = new TwitterHttpClient(_creds, _signatureEntity);
            _httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);

            return(_httpClient.GetAsync(sampleEndpointUri, HttpCompletionOption.ResponseHeadersRead));
        }
예제 #5
0
        private bool TwitterLogin(TwitterCredentials twitterCreds)
        {
            _twitterHttpClient = new TwitterHttpClient(twitterCreds);
            _loginUser         = _twitterHttpClient.GetAuthenticatedUser();
            if (_loginUser == null)
            {
                return(false);
            }

            WindowTitle          = $"Prism Twitter Reader Login: {_loginUser.Name} (@{_loginUser.ScreenName})";
            CurrentStatusMessage = "Click a 'Show' button to load the corresponding module";
            return(true);
        }
예제 #6
0
        public void Setup()
        {
            TwitterCredentials twitterCreds = null;
            string             jsonFilePath = Path.Combine(
                @"e:\FileSync\SyncProjects\TwitterReader\TwitterReader\",
                @"TwitterCredentials.json");

            Assert.IsTrue(File.Exists(jsonFilePath));
            twitterCreds = JsonHelper.DeserializeFromFile <TwitterCredentials>(jsonFilePath);
            Assert.IsNotNull(twitterCreds);
            _client = new TwitterHttpClient(twitterCreds);
            Assert.IsNotNull(_client);
        }
 public TwitterHttpClientTests()
 {
     _auth       = A.Fake <IAuthCredentials>();
     _httpClient = A.Fake <IHttpClient>();
     _client     = new TwitterHttpClient(_httpClient, _auth);
 }
예제 #8
0
 public TwitterExplorer()
 {
     twitterClient = new TwitterHttpClient();
     neo4jClient   = new Client();
 }