示例#1
0
 public Subscription(InstagramConfig config)
 {
     this.config = config;
     client      = new HttpClient {
         BaseAddress = new Uri(config.RealTimeApi)
     };
 }
示例#2
0
        protected TestBase()
        {
            // test account client id
            Config = new InstagramConfig()
            {
                ClientId = "554dfe9286994bbe98417d8dc7b69a24"
            };

            ConfigWithSecret = new InstagramConfig()
            {
                ClientId     = "554dfe9286994bbe98417d8dc7b69a24",
                CallbackUri  = "https://instasharpapi.azurewebsites.net/Realtime/Callback",
                ClientSecret = "39de8776637b47d2829cd1a4708ae180"
            };


            // dummy account data. InstaSharpTest
            Auth = new OAuthResponse()
            {
                AccessToken = "1415228826.554dfe9.502432355f084ea581b679a2f94bb350",
                User        = new Models.UserInfo {
                    Id = 1415228826
                }
            };
        }
示例#3
0
        public InstagramController(IOptions <InstagramSettings> settings, IHashTagService hashTagService)
        {
            _hashTagService    = hashTagService;
            _instagramSettings = settings.Value;

            _config = new InstagramConfig(_instagramSettings.ClientId, _instagramSettings.ClientSecret, _instagramSettings.RedirectURI, string.Empty);
        }
示例#4
0
        // GET: Request
        public async Task <ActionResult> Index(string id)
        {
            ViewBag.MenuItmes = new Dictionary <string, string>
            {
                ["Home"] = "#header",
                ["Appointment Request"] = "#apptRequest",
                ["photos"]   = "#photos",
                ["Location"] = "#location",
            };

            var instagramConfig = new InstagramConfig("2551176810b7497ebe94e79fa551ea06", "2551176810b7497ebe94e79fa551ea06");

            OAuthResponse oAuthResponse = new OAuthResponse();

            oAuthResponse.User        = null;
            oAuthResponse.AccessToken = "8915529.2551176.b8c936bdabf74276a2844e4a29394b34";

            var           users         = new Users(instagramConfig, oAuthResponse);
            UsersResponse usersResponse = await users.Search("tattoor.co", 1);

            var user = usersResponse.Data.First();

            ViewBag.Image    = user.ProfilePicture;
            ViewBag.FullName = user.FullName;
            ViewBag.Header   = user.Bio; // "Get an appointment request page (just like this one) for yourself! For free!";

            var recent = await users.Recent(user.Id, string.Empty, string.Empty, 8, null, null);

            ViewBag.Media = recent.Data.Select(media => media.Images.StandardResolution.Url).ToList();

            ViewBag.FAQs = new List <FAQ>
            {
                new FAQ
                {
                    Question = "How much do you charge?",
                    Answer   = "Appointment request pages (just like this one) are free! Get one for yourself!"
                },
                new FAQ
                {
                    Question = "If this is free, how do you make money?",
                    Answer   = "In order to generate revenue, we'll be offering other services in the future"
                },
            };


            ViewBag.Locations = new List <Location>
            {
                new Location
                {
                    Name       = "Tattoor Office",
                    Address1   = "1631 Camino De Salmon St",
                    City       = "Corona",
                    State      = "CA",
                    PostalCode = "92881"
                },
            };

            return(View());
        }
示例#5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var             clientId     = ConfigurationManager.AppSettings["client_id"];
     var             clientSecret = ConfigurationManager.AppSettings["client_secret"];
     var             redirectUri  = ConfigurationManager.AppSettings["redirect_uri"];
     var             realtimeUri  = "";
     InstagramConfig config       = new InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);
 }
示例#6
0
 public void Authentic()
 {
     var             clientId     = ConfigurationManager.AppSettings["client_id"];
     var             clientSecret = ConfigurationManager.AppSettings["client_secret"];
     var             redirectUri  = ConfigurationManager.AppSettings["redirect_uri"];
     var             realtimeUri  = "";
     InstagramConfig config       = new InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);
 }
示例#7
0
        public HomeController(IConfiguration configuration)
        {
            var clientId     = configuration.Get("InstaSharp:ClientId");
            var clientSecret = configuration.Get("InstaSharp:ClientSecret");
            var redirectUri  = configuration.Get("InstaSharp:RedirectUri");

            _config = new InstagramConfig(clientId, clientSecret, redirectUri);
        }
        public BaseApiController()
        {
            var clientId     = ConfigurationManager.AppSettings["client_id"];
            var clientSecret = ConfigurationManager.AppSettings["client_secret"];
            var redirectUri  = ConfigurationManager.AppSettings["redirect_uri"];
            var realtimeUri  = "";

            _config = new InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);
        }
示例#9
0
        protected TestBase()
        {
            bool testingNewApiNov17 = false;

            if (testingNewApiNov17)
            {
                // test account client id
                Config = new InstagramConfig()
                {
                    ClientId = "fa50f43776ba4cfdaaaa375acc5ccab7"
                };

                ConfigWithSecret = new InstagramConfig()
                {
                    ClientId     = "fa50f43776ba4cfdaaaa375acc5ccab7",
                    CallbackUri  = "https://instasharpapi.azurewebsites.net/Realtime/Callback",
                    ClientSecret = "cd0d5d2f66f146c28cef06d4f4d2dc82"
                };


                // dummy account data. InstaSharpTest
                Auth = new OAuthResponse()
                {
                    AccessToken = "1415228826.fa50f43.1069f6ca1f734e2f930f70fdc7822885",
                    User        = new Models.UserInfo {
                        Id = 1415228826
                    }
                };
            }
            else
            {
                // test account client id
                Config = new InstagramConfig()
                {
                    ClientId = "554dfe9286994bbe98417d8dc7b69a24"
                };

                ConfigWithSecret = new InstagramConfig()
                {
                    ClientId     = "554dfe9286994bbe98417d8dc7b69a24",
                    CallbackUri  = "https://instasharpapi.azurewebsites.net/Realtime/Callback",
                    ClientSecret = "39de8776637b47d2829cd1a4708ae180"
                };


                // dummy account data. InstaSharpTest
                Auth = new OAuthResponse()
                {
                    AccessToken = "1415228826.554dfe9.502432355f084ea581b679a2f94bb350",
                    User        = new Models.UserInfo {
                        Id = 1415228826
                    }
                };
            }
        }
示例#10
0
        public OAuthController()
        {
            instagramConfig = manager.GetSection <InstagramConfig>();

            client = new InstagramOAuthClient
            {
                ClientId     = instagramConfig.ClientID,
                ClientSecret = instagramConfig.ClientSecret,
                RedirectUri  = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/instagram/oauth/"
            };
        }
示例#11
0
        public static InstagramConfig GetConfig(Uri requestUri)
        {
            var url = requestUri.Scheme + System.Uri.SchemeDelimiter + requestUri.Host +
                      (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);

            var config = new InstagramConfig(
                ConfigurationManager.AppSettings["MS_WebHookReceiverSecret_InstagramId"],
                ConfigurationManager.AppSettings["MS_WebHookReceiverSecret_Instagram"],
                $"{url}/home/loginCallback");

            return(config);
        }
示例#12
0
        public static async Task <OAuthResponse> AuthByCredentialsAsync(string username, string password,
                                                                        InstagramConfig config, List <OAuth.Scope> scopes)
        {
            using (var instagram = new Instagram())
            {
                if (await instagram.LoginAsync(username, password))
                {
                    return(await instagram.GetOauthResponse(config, scopes));
                }
            }

            throw new Exception("Authentification error");
        }
示例#13
0
        public static void Initialize(HttpConfiguration config)
        {
            var clientId     = WebConfigurationManager.AppSettings["MS_WebHookReceiverSecret_InstagramId"];
            var clientSecret = WebConfigurationManager.AppSettings["MS_WebHookReceiverSecret_Instagram"];
            var webHookHost  = Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME") ?? "localhost";

            // Note: you can use the 'id' field of the callbackURI to manage multiple subscriptions with each their callback.
            var callbackUri = string.Format("https://{0}/api/webhooks/incoming/instagram", webHookHost);

            _config = new InstagramConfig(clientId, clientSecret, redirectUri: null, callbackUri: callbackUri);

            _tokens = new ConcurrentDictionary <string, OAuthResponse>();
        }
示例#14
0
        public string GetAccessLink(InstagramConfig config)
        {
            var scopes = new List <OAuth.Scope>();

            scopes.Add(OAuth.Scope.Basic);
            scopes.Add(OAuth.Scope.Public_Content);

            // scopes.Add(InstaSharp.OAuth.Scope.Comments);

            var link = OAuth.AuthLink(config.OAuthUri + "authorize", config.ClientId, config.RedirectUri, scopes, OAuth.ResponseType.Code);

            return(link);
        }
示例#15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstagramApi"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="instagramConfig">The instagram configuration.</param>
        /// <param name="oauthResponse">The oauth response.</param>
        protected InstagramApi(string endpoint, InstagramConfig instagramConfig, OAuthResponse oauthResponse)
        {
            InstagramConfig = instagramConfig;
            OAuthResponse = oauthResponse;

            var handler = new HttpClientHandler();
            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = DecompressionMethods.GZip |
                                                 DecompressionMethods.Deflate;
            }

            Client = new HttpClient(handler) { BaseAddress = new Uri(new Uri(InstagramConfig.ApiUri), endpoint) };
        }
示例#16
0
        static void Main(string[] args)
        {
            Startup();

            Console.WriteLine("Welcome!");
            Console.ReadKey();

            var clientId = Configuration.
                           var clientSecret = ConfigurationManager.AppSettings["client_secret"];
            var redirectUri = ConfigurationManager.AppSettings["redirect_uri"];
            var realtimeUri = "";

            InstagramConfig config = new InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);
        }
示例#17
0
        /// <summary>
        /// Составляет из токена OAuthResponse
        /// </summary>
        /// <param name="config">Конфиг InstaSharp</param>
        /// <param name="scopes">Список требуемых прав</param>
        /// <returns></returns>
        public async Task <OAuthResponse> GetOauthResponse(InstagramConfig config, List <OAuth.Scope> scopes)
        {
            var token = await GetAccessToken(config.ClientId, config.RedirectUri, BuildScopeForUri(scopes));

            var auth = new OAuthResponse();

            auth.AccessToken = token;
            auth.User        = new User();

            var users = new Users(config, auth);
            var self  = await users.GetSelf();

            auth.User = self.Data;

            return(auth);
        }
示例#18
0
        public InstagramAPI(string endpoint, InstagramConfig instagramConfig, OAuthResponse oauthResponse = null)
        {
            InstagramConfig = instagramConfig;
            OAuthResponse   = oauthResponse;

            var handler = new HttpClientHandler();

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = DecompressionMethods.GZip |
                                                 DecompressionMethods.Deflate;
            }

            Client = new HttpClient(handler)
            {
                BaseAddress = new Uri(new Uri(InstagramConfig.APIURI), endpoint)
            };
        }
示例#19
0
        private async void loginButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            string username = "******"; //loginTextBox.Text;
            string password = "******";  //passwordTextBox.Text;

            const string clientId     = "eea65716bf9b4124bc7ba86d9ec5ff69";
            const string clientSecret = "8f48e4223d504497bb34870551aac4c3";
            const string redirectUri  = "http://localhost/";

            var config = new InstagramConfig(clientId, clientSecret, redirectUri);
            var scopes = new List <OAuth.Scope>()
            {
                OAuth.Scope.Basic
            };

            var auth = Instagram.AuthByCredentials(username, password, config, scopes);

            var users    = new Users(config, auth);
            var userFeed = await users.Feed(null, null, null).ConfigureAwait(false);
        }
示例#20
0
        public override async Task ExecuteAsync(string generator, WebHookHandlerContext context)
        {
            // Convert the incoming data to a collection of InstagramNotifications
            var notifications = context.GetDataOrDefault <InstagramNotificationCollection>();

            // Get the config used by InstaSharp client
            InstagramConfig config = Dependencies.InstagramConfig;

            // Access media references in notifications
            foreach (var notification in notifications)
            {
                // If we have an access token then get the media using InstaSharp.
                OAuthResponse auth;
                if (Dependencies.Tokens.TryGetValue(notification.UserId, out auth))
                {
                    var           media         = new Media(config, auth);
                    MediaResponse mediaResponse = await media.Get(notification.Data.MediaId);
                }
            }
        }
示例#21
0
        protected TestBase()
        {
            // test account client id
            Config = new InstagramConfig()
            {
                ClientId = "554dfe9286994bbe98417d8dc7b69a24"
            };

            ConfigWithSecret = new InstagramConfig()
            {
                ClientId = "554dfe9286994bbe98417d8dc7b69a24",
                CallbackUri = "https://instasharpapi.azurewebsites.net/Realtime/Callback",
                ClientSecret = "39de8776637b47d2829cd1a4708ae180"
            };


            // dummy account data. InstaSharpTest
            Auth = new OAuthResponse()
            {
                AccessToken = "1415228826.554dfe9.502432355f084ea581b679a2f94bb350",
                User = new Models.UserInfo { Id = 1415228826 }
            };
        }
        /// <summary>
        /// User needs to authenticate first.
        /// </summary>
        /// <param name="strClientId"></param>
        /// <param name="strSecretId"></param>
        /// <param name="strRedirectUrl"></param>
        public static async void Authorization(string strClientId, string strSecretId, string strRedirectUrl)
        {
            InstagramConfig config = new InstagramConfig(strClientId, strSecretId, strRedirectUrl);

            var instasharp = new OAuth(config);
            var scopes     = new List <OAuth.Scope>();

            scopes.Add(OAuth.Scope.Likes);
            scopes.Add(OAuth.Scope.Comments);
            scopes.Add(OAuth.Scope.Basic);
            scopes.Add(OAuth.Scope.Follower_List);
            scopes.Add(OAuth.Scope.Public_Content);
            scopes.Add(OAuth.Scope.Relationships);
            var    link     = OAuth.AuthLink(config, scopes, OAuth.ResponseType.Token);
            var    startUri = new Uri(link);
            var    endUri   = new Uri(GlobalVariable.InstagramRedirectURI);
            string code     = string.Empty;

            try
            {
                var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);

                if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
                {
                    code = webAuthenticationResult.ResponseData.Remove(0, 37);
                    GlobalVariable.InstagramAccessToken = code;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception at Authenticate(): " + ex.Message);
            }
            //if (!string.IsNullOrEmpty(GlobalVariable.InstagramAccessToken))
            //{
            //    await GetSelf();
            //}
        }
示例#23
0
        protected TestBase()
        {
            // test account client id
            Config = new InstagramConfig()
            {
                ClientId = "fa50f43776ba4cfdaaaa375acc5ccab7"
            };

            ConfigWithSecret = new InstagramConfig()
            {
                ClientId     = "fa50f43776ba4cfdaaaa375acc5ccab7",
                CallbackUri  = "https://instasharpapi.azurewebsites.net/Realtime/Callback",
                ClientSecret = "c08dc81715f64c5eb0e462a1c5c7f234"
            };

            // dummy account data. InstaSharpTest
            Auth = new OAuthResponse()
            {
                AccessToken = "1415228826.fa50f43.1069f6ca1f734e2f930f70fdc7822885",
                User        = new Models.UserInfo {
                    Id = 1415228826
                }
            };
        }
示例#24
0
 /// <summary>
 /// Comments Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="authInfo">An instance of the AuthInfo class.</param>
 public Comments(InstagramConfig config, OAuthResponse authInfo)
     : base("media/", config, authInfo)
 {
 }
示例#25
0
 /// <summary>
 /// User Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfiguration class</param>
 public Users(InstagramConfig config)
     : this(config, null)
 {
 }
示例#26
0
 /// <summary>
 /// Relationships Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Relationships(InstagramConfig config, OAuthResponse auth)
     : base("users/", config, auth)
 {
 }
示例#27
0
 public Unauthenticated(InstagramConfig config) : base(config, "/users/")
 {
 }
示例#28
0
 /// <summary>
 /// User Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfiguration class</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Users(InstagramConfig config, OAuthResponse auth)
     : base("users/", config, auth)
 {
 }
示例#29
0
 public Authenticated(InstagramConfig config, AuthInfo auth)
     : base(config, auth, "/geographies/")
 {
     _unauthenicated = new Unauthenticated(config);
 }
示例#30
0
 /// <summary>
 /// Geographies Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Geographies(InstagramConfig config, OAuthResponse auth = null)
     : base("geographies/", config, auth)
 {
 }
 public Unauthenticated(InstagramConfig config) : base(config, "/geographies/") {}
示例#32
0
 public InstagramAPI(InstagramConfig instagramConfig, AuthInfo authInfo, string endpoint) {
     InstagramConfig = instagramConfig;
     AuthInfo = authInfo;
     Uri = InstagramConfig.APIURI + endpoint;
 }
示例#33
0
 /// <summary>
 /// Locations Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstaGram config class</param>
 public Locations(InstagramConfig config)
     : this(config, null)
 {
 }
示例#34
0
 public Subscription(InstagramConfig config)
 {
     this.config = config;
     client = new HttpClient {BaseAddress = new Uri(config.RealTimeApi)};
 }
示例#35
0
 public Authenticated(InstagramConfig config, AuthInfo auth)
     : base(config, auth, "/search/") {
         _unauthenticated = new Unauthenticated(config);
 }
示例#36
0
 /// <summary>
 /// Likes Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Likes(InstagramConfig config)
     : this(config, null)
 {
 }
示例#37
0
 /// <summary>
 /// Construct a Subscription Endpoint
 /// </summary>
 /// <param name="config"></param>
 public Subscription(InstagramConfig config)
     : base(config.RealTimeApi, config)
 {
 }
示例#38
0
 /// <summary>
 /// Locations Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstaGram config class</param>
 /// <param name="auth">Optional: An instance of the AuthInfo class</param>
 public Locations(InstagramConfig config, OAuthResponse auth = null)
     : base("locations/", config, auth)
 {
 }
示例#39
0
 public InstagramAPI(InstagramConfig instagramConfig, string endpoint) : this(instagramConfig, new AuthInfo(), endpoint) { }
 public Unauthenticated(InstagramConfig config)
     : base(config, "/media/") { }
示例#41
0
 public Unauthenticated(InstagramConfig config) : base(config, "/geographies/")
 {
 }
示例#42
0
 /// <summary>
 /// Media Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Media(InstagramConfig config, OAuthResponse auth)
     : base("media/", config, auth)
 {
 }
示例#43
0
 /// <summary>
 /// Comments Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Comments(InstagramConfig config)
     : this(config, null)
 {
 }
示例#44
0
 /// <summary>
 /// Relationships Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Relationships(InstagramConfig config, OAuthResponse auth)
     : base("users/", config, auth)
 {
 }
示例#45
0
 /// <summary>
 /// Relationships Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Relationships(InstagramConfig config)
     : this(config, null)
 {
 }
示例#46
0
 /// <summary>
 /// Geographies Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Geographies(InstagramConfig config)
     : this(config, null)
 {
 }
示例#47
0
 public Unauthenticated(InstagramConfig config) : base(config, "/media/")
 {
 }
示例#48
0
 /// <summary>
 /// Media Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the AuthInfo class.</param>
 public Media(InstagramConfig config, OAuthResponse auth = null)
     : base("media/", config, auth)
 {
 }
示例#49
0
 /// <summary>
 /// User Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfiguration class</param>
 /// <param name="OAuthResponse">An instance of the AuthInfo class</param>
 public Users(InstagramConfig config, OAuthResponse OAuthResponse = null)
     : base("users/", config, OAuthResponse)
 {
 }
 public Unauthenticated(InstagramConfig config) : base(config, "/locations/") { }
示例#51
0
 /// <summary>
 /// Media Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Media(InstagramConfig config)
     : this(config, null)
 {
 }
示例#52
0
 /// <summary>
 /// Likes Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 /// <param name="auth">An instance of the OAuthResponse class.</param>
 public Likes(InstagramConfig config, OAuthResponse auth)
     : base("media/", config, auth)
 {
 }
示例#53
0
 /// <summary>
 /// Relationships Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Relationships(InstagramConfig config)
     : this(config, null)
 {
 }
示例#54
0
 public Authenticated(InstagramConfig config, AuthInfo authInfo) :
     base(config, authInfo, "/media/") {
     _unauthenticated = new Unauthenticated(config);
 }
示例#55
0
        /// <summary>
        /// Tag Endpoints
        /// </summary>
        /// <param name="config">An instance of the InstagramConfig class</param>
        public Tags(InstagramConfig config) : this(config, null)
        {

        }
示例#56
0
        /// <summary>
        /// Tag Endpoints
        /// </summary>
        /// <param name="config">An instance of the InstagramConfig class</param>
        /// <param name="auth">An instance of the OAuthResponse class.</param>
        public Tags(InstagramConfig config, OAuthResponse auth) : base("tags/", config, auth)
        {

        }
示例#57
0
 public Authenticated(InstagramConfig config, AuthInfo auth) : base(config, auth, "/media/")
 {
     _unauthenticated = new Unauthenticated(config);
 }
示例#58
0
        internal InstagramApi(string endpoint, InstagramConfig instagramConfig)
            : this(endpoint, instagramConfig, null)
        {

        }
示例#59
0
 /// <summary>
 /// Media Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Media(InstagramConfig config)
     : this(config, null)
 {
 }
示例#60
0
 /// <summary>
 /// Geographies Endpoints
 /// </summary>
 /// <param name="config">An instance of the InstagramConfig class.</param>
 public Geographies(InstagramConfig config)
     : base("geographies/", config)
 {
 }