Пример #1
0
        /*
        public FacebookLayer()
        {
            authorizer = new CanvasAuthorizer { Perms = "publish_stream" };
            if (authorizer.Authorize())
            {
                fbClient = new FacebookClient(CurrentSession.AccessToken);
                User = new FacebookUser();
                try
                {
                    var me = (IDictionary<string, object>) fbClient.Get("me");

                    User.FacebookId = (string) me["id"];
                    User.FacebookName = (string) me["first_name"];
                }
                catch
                {
                    isAccessTokenValid = false;
                    return;
                }
                isAccessTokenValid = true;
                IDictionary<string, object> friendsData = (IDictionary<string, object>) fbClient.Get("me/friends");
                facebookData = new FacebookData(User, friendsData);
                SortedFriends = facebookData.SortedFriends;
            }
        }
        */
        public FacebookLayer(CanvasAuthorizer auth)
        {
            this.authorizer = auth;
            if (this.authorizer.Authorize())
            {
                fbClient = new FacebookClient(CurrentSession.AccessToken);
                User = new FacebookUser();
                try
                {
                    var me = (IDictionary<string, object>) fbClient.Get("me");

                    User.FacebookId = (string) me["id"];
                    User.FacebookName = (string) me["first_name"];
                }
                catch
                {
                    isAccessTokenValid = false;
                    return;
                }
                isAccessTokenValid = true;
                IDictionary<string, object> friendsData = (IDictionary<string, object>) fbClient.Get("me/friends");
                facebookData = new FacebookData(User, (IList<object>)friendsData["data"]);

            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FacebookData"/> class.initializes User and Friends information and sorts friends
        /// </summary>
        /// <param name="user">User for friend inforamtion</param>
        /// <param name="friendsData">person's friends array</param>
        public FacebookData(FacebookUser user, IList<object> friendsData)
        {
            this.user = user;
            foreach (dynamic o in friendsData)
            {
                FacebookUser f = new FacebookUser { FacebookName = o.name, FacebookId = o.id };
                this.FriendsData.Add(f);
            }

            LoadDtLocations();
        }