Beispiel #1
0
        // GET: Instagram
        public ActionResult Index()
        {
            HomeModel userModel     = new HomeModel();
            Users     userEndpoints = new Users();

            if (!Request.IsAuthenticated)
            {
                var code = Request.QueryString["code"];
                if (!string.IsNullOrEmpty(code))
                {
                    InstagramAuth instagramAuth   = new InstagramAuth();
                    InstaConfig   instagramConfig = new InstaConfig();
                    instagramConfig.redirect_uri  = "http://localhost:58065/Instagram/Index";
                    instagramConfig.client_secret = "f975c1bf53f64aecb7bf63dda0d996d7";
                    instagramConfig.client_id     = "01b344efcdb445068a20f30391bea917";
                    userModel.user = instagramAuth.GetAccessToken(code, instagramConfig);

                    FormsAuthentication.SetAuthCookie(userModel.user.access_token, true);
                    userModel.UserFeed  = userEndpoints.GetUserMedia("2368860595", userModel.user.access_token);
                    ViewBag.UserProfile = userEndpoints.GetUserSelf(userModel.user.access_token).data;
                }
            }
            else
            {
                userModel.user = new OuthUser();
                userModel.user.access_token = HttpContext.User.Identity.Name;
                ViewBag.UserProfile         = userEndpoints.GetUserSelf(userModel.user.access_token).data;
                userModel.UserFeed          = userEndpoints.GetUserMedia("2368860595", userModel.user.access_token);
            }
            return(View(userModel.UserFeed));
        }
        //
        // GET: /Instagram/

        public ActionResult Index()
        {
            HomeModel mdl = new HomeModel();

            mdl.profilmodel = new ProfileModel();
            Users usr = new Users();

            if (!Request.IsAuthenticated)
            {
                var code = Request.QueryString["code"];
                if (!string.IsNullOrEmpty(code))
                {
                    InstagramAuth ia = new InstagramAuth();
                    InstaConfig   ic = new InstaConfig();
                    ic.redirect_uri  = "http://localhost:51963/Instagram";
                    ic.client_secret = "";
                    ic.client_id     = "";
                    mdl.user         = ia.GetAccessToken(code, ic);
                    FormsAuthentication.SetAuthCookie(mdl.user.access_token, true);
                    mdl.UserFeed = usr.GetUserSelfFeed(mdl.user.access_token);
                }
            }
            else
            {
                mdl.user = new OuthUser();
                mdl.user.access_token  = HttpContext.User.Identity.Name;
                mdl.user.user          = usr.GetUserSelf(mdl.user.access_token).data;
                mdl.UserFeed           = usr.GetUserSelfFeed(mdl.user.access_token);
                mdl.profilmodel.counts = mdl.user.user.counts;
            }
            mdl.pagetype = "home";
            return(View(mdl));
        }
        public ActionResult InstagramReturnUrl(string code)
        {
            InstagramAuth instagramAuth = new InstagramAuth();

            OuthUser user         = instagramAuth.GetAccessToken(code, instaConfig); // get user who loged in with an access_token
            string   access_token = user.access_token;


            Likes likes = new Likes();

            string idImage = "1476852486660100934_2015123882";

            likes.LikeMedia(idImage, access_token);

            return(View());
        }