public void Set(HttpContext context)
        {
            // check if we are authenticated already and for the auth object
            if (context.Session["InstaSharp.Authenticated"] != null) {
                isAuthenticated = false; // (bool)context.Session["InstaSharp.Authenticated"];

                if (isAuthenticated)
                {
                    oauthResponse = (OAuthResponse)context.Session["InstaSharp.AuthInfo"];

                    // if we are authenticated, then we need to check and see if there is a corresponding
                    // signalr clientid registered in the database
                }
            }

            // check the session for a config object
            if (context.Session["InstaSharp.Config"] == null)
            {
                // if we are not authenticated, create a config object
                var clientId = ConfigurationManager.AppSettings.Get("client_id");
                var clientSecret = ConfigurationManager.AppSettings.Get("client_secret");
                var redirectUri = ConfigurationManager.AppSettings.Get("redirect_uri");
                var realtimeUri = "";

                config = new InstaSharp.InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);

                context.Session.Add("InstaSharp.Config", config);
            }
            else {
                // just get it off the session and store it in the config variable
                config = (InstagramConfig)context.Session["InstaSharp.Config"];
            }
        }
示例#2
0
        private IList <string> GetPhotos()
        {
            var photos = new List <string>();

            try
            {
                var config        = new InstaSharp.InstagramConfig("https://api.instagram.com/v1", "https://api.instagram.com/oauth", "ec801d2b6eff42aaa5dc1d18bfc5e74b", "9c2aa521f5df4019b298a816bcfd4a4c", "http://localhost:56137/");
                var tagSearch     = new InstaSharp.Endpoints.Tags.Unauthenticated(config);
                var searchResults = tagSearch.Recent(HttpUtility.UrlEncode("f1"));

                photos.AddRange(searchResults.Data.Select(x => x.Images.LowResolution.Url).ToList());

                return(photos);
            }
            catch (Exception ex)
            {
                //load the fake photos
                //todo
                photos.Add("http://google.com/image.jpg");
            }
            return(photos);
        }
示例#3
0
        private IList<string> GetPhotos()
        {
            var photos = new List<string>();
            try
            {
                var config = new InstaSharp.InstagramConfig("https://api.instagram.com/v1", "https://api.instagram.com/oauth", "ec801d2b6eff42aaa5dc1d18bfc5e74b", "9c2aa521f5df4019b298a816bcfd4a4c", "http://localhost:56137/");
                var tagSearch = new InstaSharp.Endpoints.Tags.Unauthenticated(config);
                var searchResults = tagSearch.Recent(HttpUtility.UrlEncode("f1"));

                photos.AddRange(searchResults.Data.Select(x => x.Images.LowResolution.Url).ToList());

                return photos;
            }
            catch (Exception ex)
            {
                //load the fake photos
                //todo
                photos.Add("http://google.com/image.jpg");
            }
            return photos;
        }