public async void FbFeed(ListItemTemplate session) { FacebookClient _fb = new FacebookClient(session.accessToken); dynamic parameters = new ExpandoObject(); parameters.access_token = session.accessToken; dynamic result = null; try{ result = await _fb.GetTaskAsync("me/home", parameters); } catch (FacebookOAuthException e) { Debug.WriteLine("Problem: \n" + e.Message); App.Progress.IsActive = false; App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed; return; } var friendResult = (IDictionary<string, object>)result; var data = (IEnumerable<object>)friendResult["data"]; FacebookFeed fbFeed = new FacebookFeed(session); foreach (var item in data) { var posts = (IDictionary<string, object>)item; FacebookPost post = new FacebookPost(posts, session.userSession); fbFeed.feedStack.Children.Add(post); } fbFeed.nextPage = (String)((IDictionary<string, object>)friendResult["paging"])["next"]; fbFeed.previousPage = (String)((IDictionary<string, object>)friendResult["paging"])["previous"]; await Task.Run(() => { fbFeed.realtimeUpdate(); }); await Task.Run(() => { fbFeed.timeUpdate(); }); rightPane.Children.Add(fbFeed); App.Progress.IsActive = false; App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }
public async void FacebookHandle(String accessToken, ListView list){ FacebookClient _fb = new FacebookClient(accessToken); dynamic parameters = new ExpandoObject(); parameters.access_token = accessToken; parameters.fields = "id,name"; dynamic result = await _fb.GetTaskAsync("me", parameters); App.FacebookId = result.id; string profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", App.FacebookId, "large", _fb.AccessToken); ListItemTemplate listItem = new ListItemTemplate(); listItem.siteTitle.Text = "Facebook"; listItem.profilePic.Source = new BitmapImage(new Uri(profilePictureUrl)); listItem.name.Text = result.name; listItem.accessToken = _fb.AccessToken; listItem.userSession = new ViewModel.Facebook.FacebookUserSession(_fb); list.Items.Insert(list.Items.Count - 1, listItem); }
private void LoadUserInfo() { this.siteList.Items.Clear(); ListItemTemplate addNew = new ListItemTemplate(); addNew.siteTitle.Text = "+ Add Account"; this.siteList.Items.Add(addNew); var dbPath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, dbName); SiteListSolution siteList = new SiteListSolution(); if (IsInternet()) { connectTest.Visibility = Windows.UI.Xaml.Visibility.Collapsed; connectTest2.Visibility = Windows.UI.Xaml.Visibility.Visible; using (var db = new SQLite.SQLiteConnection(dbPath)) { db.CreateTable<Authorization>(); ObservableCollection<Authorization> list = new ObservableCollection<Authorization>(db.Query<Authorization>("select * from Authorization")); for (int i = 0; i < list.Count; i++) { if (list[i].Site.Equals("Facebook")) { siteList.FacebookHandle(list[i].AccessToken, this.siteList); } } } } else { connectTest2.Visibility = Windows.UI.Xaml.Visibility.Collapsed; connectTest.Visibility = Windows.UI.Xaml.Visibility.Visible; } }