public Subscription(InstagramConfig config) { this.config = config; client = new HttpClient { BaseAddress = new Uri(config.RealTimeApi) }; }
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 } }; }
public InstagramController(IOptions <InstagramSettings> settings, IHashTagService hashTagService) { _hashTagService = hashTagService; _instagramSettings = settings.Value; _config = new InstagramConfig(_instagramSettings.ClientId, _instagramSettings.ClientSecret, _instagramSettings.RedirectURI, string.Empty); }
// 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()); }
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); }
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); }
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); }
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 } }; } }
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/" }; }
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); }
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"); }
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>(); }
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); }
/// <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) }; }
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); }
/// <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); }
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) }; }
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); }
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); } } }
/// <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(); //} }
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 } }; }
/// <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) { }
/// <summary> /// User Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfiguration class</param> public Users(InstagramConfig config) : this(config, null) { }
/// <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) { }
public Unauthenticated(InstagramConfig config) : base(config, "/users/") { }
/// <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) { }
public Authenticated(InstagramConfig config, AuthInfo auth) : base(config, auth, "/geographies/") { _unauthenicated = new Unauthenticated(config); }
/// <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/") {}
public InstagramAPI(InstagramConfig instagramConfig, AuthInfo authInfo, string endpoint) { InstagramConfig = instagramConfig; AuthInfo = authInfo; Uri = InstagramConfig.APIURI + endpoint; }
/// <summary> /// Locations Endpoints /// </summary> /// <param name="config">An instance of the InstaGram config class</param> public Locations(InstagramConfig config) : this(config, null) { }
public Subscription(InstagramConfig config) { this.config = config; client = new HttpClient {BaseAddress = new Uri(config.RealTimeApi)}; }
public Authenticated(InstagramConfig config, AuthInfo auth) : base(config, auth, "/search/") { _unauthenticated = new Unauthenticated(config); }
/// <summary> /// Likes Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Likes(InstagramConfig config) : this(config, null) { }
/// <summary> /// Construct a Subscription Endpoint /// </summary> /// <param name="config"></param> public Subscription(InstagramConfig config) : base(config.RealTimeApi, config) { }
/// <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) { }
public InstagramAPI(InstagramConfig instagramConfig, string endpoint) : this(instagramConfig, new AuthInfo(), endpoint) { }
public Unauthenticated(InstagramConfig config) : base(config, "/media/") { }
public Unauthenticated(InstagramConfig config) : base(config, "/geographies/") { }
/// <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) { }
/// <summary> /// Comments Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Comments(InstagramConfig config) : this(config, null) { }
/// <summary> /// Relationships Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Relationships(InstagramConfig config) : this(config, null) { }
/// <summary> /// Geographies Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Geographies(InstagramConfig config) : this(config, null) { }
/// <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) { }
/// <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/") { }
/// <summary> /// Media Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Media(InstagramConfig config) : this(config, null) { }
/// <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) { }
public Authenticated(InstagramConfig config, AuthInfo authInfo) : base(config, authInfo, "/media/") { _unauthenticated = new Unauthenticated(config); }
/// <summary> /// Tag Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class</param> public Tags(InstagramConfig config) : this(config, null) { }
/// <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) { }
public Authenticated(InstagramConfig config, AuthInfo auth) : base(config, auth, "/media/") { _unauthenticated = new Unauthenticated(config); }
internal InstagramApi(string endpoint, InstagramConfig instagramConfig) : this(endpoint, instagramConfig, null) { }
/// <summary> /// Geographies Endpoints /// </summary> /// <param name="config">An instance of the InstagramConfig class.</param> public Geographies(InstagramConfig config) : base("geographies/", config) { }