public MeDTO GetMe()
        {
            dynamic me = FbClient.Get(FacebookHelper.MeQuery);

            if (me != null)
            {
                return(_builder.BuildMe(me));
            }

            return(null);
        }
        public IEnumerable <FacebookFriendDTO> GetFriends()
        {
            dynamic friends = FbClient.Get(FacebookHelper.FriendsQuery);
            var     data    = friends.data as IEnumerable <dynamic>;

            var results = new List <FacebookFriendDTO>();

            data.ForEach(f => {
                if (f.installed != null && f.installed)
                {
                    results.Add(_builder.BuildFacebookFriend(f));
                }
            });

            return(results);
        }
示例#3
0
/*
 *      /// <summary>
 *      /// Initializes a new instance of the FacebookLayer class
 *      /// </summary>
 *      public FacebookLayer()
 *      {
 *          this.Auth = new Authorizer();
 *
 *          if (this.Auth.Authorize())
 *          {
 *              this.FbClient = new FacebookClient(CurrentSession.AccessToken);
 *              this.User = new FacebookUser();
 *              try
 *              {
 *                  var me = (IDictionary<string, object>) this.FbClient.Get("me");
 *
 *                  this.User.FacebookId = (string) me["id"];
 *                  this.User.FacebookName = (string) me["first_name"];
 *              }
 *              catch
 *              {
 *                  this.IsAccessTokenValid = false;
 *                  return;
 *              }
 *
 *              this.IsAccessTokenValid = true;
 *              IDictionary<string, object> friendsData = (IDictionary<string, object>) this.FbClient.Get("me/friends");
 *              this.facebookData = new FacebookData(this.User, friendsData);
 *              this.SortedFriends = this.facebookData.SortedFriends;
 *          }
 *      }
 */

        /// <summary>
        /// Initializes a new instance of the FacebookLayer class using authorization
        /// </summary>
        /// <param name="auth">authorization instance</param>
        public FacebookLayer(Authorizer auth)
        {
            this.Auth = auth;

            if (auth.Authorize())
            {
                this.FbClient = new FacebookClient(CurrentSession.AccessToken);
                this.User     = new FacebookUser();
                try
                {
                    var me = (IDictionary <string, object>) this.FbClient.Get("me");

                    this.User.FacebookId   = (string)me["id"];
                    this.User.FacebookName = (string)me["first_name"];
                }
                catch
                {
                    this.IsAccessTokenValid = false;
                    return;
                }

                this.IsAccessTokenValid = true;
                IDictionary <string, object> friendsData = (IDictionary <string, object>)FbClient.Get("me/friends");
                facebookData = new FacebookData(User, (IList <object>)friendsData["data"]);
            }
        }