Ejemplo n.º 1
0
        public async Task <ActionResult> FB_GetFeed()
        {
            var access_token = Convert.ToString(HttpContext.Items["access_token"]);

            if (access_token != null)
            {
                try
                {
                    var appsecret_proof = access_token.generateAppSecretProof();

                    FacebookProfileViewModel fbm = new FacebookProfileViewModel();
                    var imgurl = fbm.ImageURL;
                    FacebookPostViewModel fbpm = new FacebookPostViewModel();
                    var     fb     = new FacebookClient(access_token);
                    dynamic myFeed = await fb.GetTaskAsync(
                        ("me/feed?fields=id,from {{id,name,picture{{url}}}},story,picture,link,name,description,message,type,created_time,likes,comments").GraphAPICall(appsecret_proof));

                    var postList = new List <FacebookPostViewModel>();
                    foreach (dynamic post in myFeed.data)
                    {
                        postList.Add(DynamicExtention.ToStatic <FacebookPostViewModel>(post));
                    }
                    fbpm.From_Picture_Url = imgurl;

                    return(PartialView(postList));
                }
                catch (Exception) { throw; }
            }
            else
            {
                throw new HttpException(404, "missing access token");
            }
        }
        // GET: Facebook
        public async Task<ActionResult> Index()
        {
            var access_token = HttpContext.Items["access_token"].ToString();
            if(access_token != null)
            {
                try
                {
                    var appsecret_proof = access_token.GenerateAppSecretProof();

                    var fb = new FacebookClient(access_token);
                    //Get current user's profile
                    dynamic myInfo =
                        await fb.GetTaskAsync("me?fields=first_name,last_name,link,locale,email,name,birthday,gender,location,bio,age_range".GraphAPICall(appsecret_proof));

                    //var facebookProfile = DynamicExtension.ToStatic<FacebookProfileViewModel>(myInfo);

                    //get curent profile
                    dynamic profileImgResult =
                        await fb.GetTaskAsync("{0}/picture?width=200&height=200&redirect=false".GraphAPICall((string)myInfo.id, appsecret_proof));
                    //facebookProfile.ImageUrl = profileImgResult.data.url;
                    var facebookProfile = new FacebookProfileViewModel()
                    {
                        
                    }
                }
                catch (Exception)
                {
                    
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        public FacebookProfileView(string token)
        {
            InitializeComponent();

            viewModel           = new FacebookProfileViewModel();
            this.BindingContext = viewModel;
            this.token          = token;
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Index()
        {
            var access_token = HttpContext.Items["access_token"].ToString();

            if (access_token != null)
            {
                try
                {
                    var     appsecret_proof = access_token.GenerateAppSecretProof();
                    var     fb     = new FacebookClient(access_token);
                    dynamic myInfo = await fb.GetTaskAsync(
                        "me?fields=first_name,last_name,link,locale,email,name,gender,location,bio,age_range"
                        .GraphAPICall(appsecret_proof));

                    dynamic profileImgResult = await fb.GetTaskAsync(
                        "{0}/picture?width=200&height=200&redirect=false".GraphAPICall((string)myInfo.id,
                                                                                       appsecret_proof));

                    var facebookProfile = new FacebookProfileViewModel()
                    {
                        FirstName = myInfo.first_name,
                        LastName  = myInfo.last_name,
                        Locale    = myInfo.locale,
                        Email     = myInfo.email,
                        ImageUrl  = profileImgResult.data.url,
                        FullName  = myInfo.name,
                        Birthday  = myInfo.birthday,
                        Gender    = myInfo.gender,
                        Location  = myInfo.location,
                        Bio       = myInfo.bio,
                        Age       = myInfo.age_range
                    };
                    return(View(facebookProfile));
                }
                catch (FacebookApiLimitException e)
                {
                    throw new HttpException(500, e.Message);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        // GET: Facebook
        public async Task <ActionResult> Index()
        {
            var access_token    = HttpContext.Items["access_token"].ToString();
            var appsecret_proof = access_token.GenerateAppSecretProof();

            var facebookClient = new FacebookClient();

            var result = await facebookClient.GetAsync <dynamic>(
                access_token, "me", "fields=first_name,last_name,link,locale,email,birthday,gender,location,age_range");

            // Image overloads FacebookProfileViewModel. IDK why o.O

            //var profileImgResult = await facebookClient.GetAsync<dynamic>(access_token, $"{ result.id}", "/picture?width=200&height=200&redirec=false");



            if (result == null)
            {
                throw new HttpException(400, "Jebem li ga");
            }

            var facebookProfile = new FacebookProfileViewModel
            {
                Id        = result.id,
                Email     = result.email,
                Name      = result.name,
                FirstName = result.first_name,
                LastName  = result.last_name,
                Locale    = result.locale,
                LinkURL   = result.link,
                Gender    = result.gender,
                //ImageURL = profileImgResult.data.url.ToString()
            };

            return(View(facebookProfile));
        }