static void CommentTest()
        {
            var username = Credential.GetYourUsername();
            var password = Credential.GetYourPassword();

            var user = new InstagramClient(username, password);

            var loginResult = user.LogIn();

            if (loginResult.authenticated)
            {
                var commentResult = user.Comment("1291753606881517996", "Good art");
                Console.WriteLine(commentResult.status);
                Console.WriteLine(commentResult.id);
                Console.WriteLine(commentResult.text);
                Console.WriteLine(commentResult.created_time);

                var commentFrom = commentResult.from;
                Console.WriteLine(commentFrom.id);
                Console.WriteLine(commentFrom.full_name);
                Console.WriteLine(commentFrom.username);
                Console.WriteLine(commentFrom.profile_picture);
            }

            Console.ReadLine();
        }
Exemplo n.º 2
0
        private void ProcessProviderResult()
        {
            ProviderName = OpenAuth.GetProviderNameFromCurrentRequest();
            FedeFacebookClient.RewriteRequest();
            InstagramClient.RewriteRequest();
            GoogleOAuth2Client.RewriteRequest();

            var redirectUrl = "~/ExternalLogin.aspx";
            var returnUrl   = Request.QueryString["ReturnUrl"];

            if (!String.IsNullOrEmpty(returnUrl))
            {
                redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(returnUrl);
            }


            var authResult = OpenAuth.VerifyAuthentication(redirectUrl);

            if (!authResult.IsSuccessful)
            {
                Title = "External login failed";
                userNameForm.Visible = false;
                ModelState.AddModelError("Provider", String.Format("External login {0} failed.", ProviderDisplayName));

                Trace.Warn("OpenAuth", String.Format("There was an error verifying authentication with {0})", ProviderName), authResult.Error);
                return;
            }
            ProviderName       = authResult.Provider;
            ProviderUserId     = authResult.ProviderUserId;
            ProviderUserName   = authResult.UserName;
            Form.Action        = ResolveUrl(redirectUrl);
            imgSocial.ImageUrl = AuthHelper.GetSocialImage(authResult);
        }
Exemplo n.º 3
0
        public async Task <IResult <InstaMediaList> > GetMediaByUser(string User)
        {
            try
            {
                var Credentials = new UserSessionData();
                Credentials.UserName = "******";
                Credentials.Password = "******";

                var Api = InstagramClient
                          .SetUser(Credentials)
                          .Build();

                var Result = await Api.LoginAsync();

                Console.WriteLine(Result.Succeeded);

                var Parameters = PaginationParameters.MaxPagesToLoad(10);
                IResult <InstaMediaList> Media = await Api.GetUserMediaAsync(User, Parameters);
                await UploadMedia(Media, User);

                return(Media);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(null);
        }
Exemplo n.º 4
0
        public ColorProfile(InstagramClient instagramClient)
        {
            InitializeComponent();
            _bitmapList = new List <Bitmap>();
            _colorImage = new List <Bitmap>();

            _instagramClient = instagramClient;
        }
 public SocialNetworkUser[] GetSubscribers(String userName)
 {
     InstagramUser[]     users       = new InstagramClient().GetSubscribers(userName);
     SocialNetworkUser[] subscribers = new SocialNetworkUser[users.Length];
     for (int i = 0; i < subscribers.Length; i++)
     {
         subscribers[i].UserName = users[i].UserName;
     }
     return(subscribers);
 }
        public string ReceiveUpdate()
        {
            string clientId     = "YOUR_CLIENT_ID";
            string clientSecret = "YOUR_CLIENT_SECRET";

            InstagramClient instagramClient = new InstagramClient(clientId, clientSecret, null);

            if (Request.HttpMethod.Equals("GET", StringComparison.OrdinalIgnoreCase))
            {
                string verifyToken = "YOUR_VERIY_TOKEN";

                var hubVeifyTokenParam = Request.Params["hub.verify_token"];
                var hubChallengeParam  = Request.Params["hub.challenge"];
                var hubModeParam       = Request.Params["hub.mode"];

                try
                {
                    instagramClient.SubscriptionsEndpoints.VerifyGetSubscription(verifyToken, hubModeParam, hubVeifyTokenParam, hubChallengeParam);
                    return(hubChallengeParam);
                }
                catch (SubscriptionVerifyException ex)
                {
                    //Log exception
                    return(null);
                }
            }
            else
            {
                var xHubSignature = Request.Headers["x-hub-signature"];
                Request.InputStream.Position = 0;
                string realTimeUpdatesJson = null;
                using (var streamReader = new StreamReader(Request.InputStream))
                {
                    realTimeUpdatesJson = streamReader.ReadToEnd();
                }

                try
                {
                    instagramClient.SubscriptionsEndpoints.VerifyPostSubscription(xHubSignature, realTimeUpdatesJson);

                    //I use Json.NET for parsing the result
                    var realTimeUpdates = JsonConvert.DeserializeObject(realTimeUpdatesJson);

                    //You can deserialize json result to one of the models in InstagramCSharp or to your custom model
                    //var realTimeUpdates = JsonConvert.DeserializeObject<List<RealTimeUpdate>>(realTimeUpdatesJson);
                }
                catch (SubscriptionVerifyException ex)
                {
                    //Log exception
                }

                return(null);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new instance of the instagram client class
        /// </summary>
        /// <param name="instagramSettings"></param>
        /// <returns></returns>
        private InstagramClient GetInstagramClient(BotSettings instagramSettings)
        {
            // Get the settings
            var igUsername = instagramSettings.InstagramUsername;
            var igPassword = instagramSettings.InstagramPassword;
            var igTags     = instagramSettings.InstagramTags;

            var igClient = new InstagramClient(igUsername, igPassword, igTags);

            return(igClient);
        }
        public async void SaveCredentials(string token)
        {
            if (!string.IsNullOrWhiteSpace(token))
            {
                var InstagramClient = new InstagramClient(token);

                var info = await InstagramClient.GetMyUserAsync();

                //info.Data.Username;
            }
        }
        public async void runApp(String token)
        {
            var InstagramClient = new InstagramClient(token);

            await InstagramClient.GetMyUserAsync();

            Console.Write(InstagramClient.GetMyUserAsync());
            var mainActivity = new Intent(this, typeof(WeatherScreen));

            mainActivity.PutExtra("UserToken", token);
            StartActivity(mainActivity);
        }
Exemplo n.º 10
0
        public SocialNetworkUser[] GetSubscribers(string name)
        {
            var list       = new List <SocialNetworkUser>();
            var instClient = new InstagramClient();
            var usersInst  = instClient.GetSubscribers(name);

            usersInst.ToList().ForEach(u => list.Add(
                                           new SocialNetworkUser
            {
                UserName = u.UserName
            }));
            return(list.ToArray());
        }
Exemplo n.º 11
0
        public BotForLikes(InstagramClient instagramClient)
        {
            InitializeComponent();

            _instagramClient = instagramClient;

            _rand      = new Random();
            _usersList = new List <InstagramUser>();
            _cts       = new CancellationTokenSource();
            _token     = _cts.Token;

            GetTextFile(_numberLikesDayFileName);
            SetNumberLikesDayLabel();
        }
Exemplo n.º 12
0
        public SocialNetworkUser[] DoAlgorithm(String userName)

        {
            List <SocialNetworkUser> users = new List <SocialNetworkUser>();

            InstagramUser[] instSubscribers = new InstagramClient().GetSubscribers(userName);
            for (int i = 0; i < instSubscribers.Length; i++)
            {
                var user = new SocialNetworkUser();
                user.UserName = instSubscribers[i].UserName;
                users.Add(user);
            }
            return(users.ToArray());
        }
        public SocialNetworkUser[] GetSubscribers(String userName)
        {
            var instagramClient          = new InstagramClient();
            var instagramUserSubscribers = instagramClient.GetSubscribers(userName);
            var socialNetworkUsers       = new List <SocialNetworkUser>();

            foreach (InstagramUser instagramUser in instagramUserSubscribers)
            {
                socialNetworkUsers.Add(new SocialNetworkUser {
                    UserName = instagramUser.UserName
                });
            }
            return(socialNetworkUsers.ToArray());
        }
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            string token = Intent.GetStringExtra("UserToken") ?? "False";

            Console.WriteLine(token);

            var InstagramClient = new InstagramClient(token);

            MediasResponse imageResponse = new MediasResponse();

            imageResponse = await InstagramClient.GetMyUserAsync();

            //Console.WriteLine("this");
        }
Exemplo n.º 15
0
        public UserActivity(InstagramClient instagramClient)
        {
            InitializeComponent();

            _instagramClient = instagramClient;

            _mediaLikerList    = new List <MediaLiker>();
            _userFollowersList = new List <InstaUserShort>();

            _activeFollowersUsersList    = new List <InstagramUser>();
            _activeNotFollowersUsersList = new List <InstagramUser>();

            ActiveFollowersUsers.InitializationFollowersList(_activeFollowersUsersList, "ActiveFollowersUsersList");
            ActiveNotFollowersUsers.InitializationFollowersList(_activeNotFollowersUsersList, "ActiveNotFollowersUsersList");
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var username = Credential.GetYourUsername();
            var password = Credential.GetYourPassword();

            var user        = new InstagramClient(username, password);
            var loginResult = user.LogIn();

            if (loginResult.authenticated)
            {
                // tested on December 11 2018
                var theRockpublicInfo = user.GetPublicInfo("therock");
            }
            Console.ReadLine();
        }
Exemplo n.º 17
0
        static void ReportTest()
        {
            var username = Credential.GetYourUsername();
            var password = Credential.GetYourPassword();

            var user        = new InstagramClient(username, password);
            var loginResult = user.LogIn();

            if (loginResult.authenticated)
            {
                var commentResult = user.Report("1289832948493489827", Mmosoft.Instagram.Sdk.Models.ReportReasonId.NudityOrPornography);
                Console.WriteLine(commentResult.status);
            }

            Console.ReadLine();
        }
Exemplo n.º 18
0
 /// <summary>
 /// Attempts to login to instagram
 /// </summary>
 /// <param name="instagramClient"></param>
 /// <returns></returns>
 private bool LoginInstagram(InstagramClient instagramClient)
 {
     // Attempt to login
     try
     {
         instagramClient.Login();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Unable to login to instagram account of {BotName}" +
                           $" {Environment.NewLine}" +
                           $" {ex.Message}");
         return(false);
     }
 }
Exemplo n.º 19
0
        public BotForLikes(InstagramClient instagramClient)
        {
            InitializeComponent();

            _instagramClient = instagramClient;

            _rand      = new Random();
            _usersList = new List <InstagramUser>();
            _cts       = new CancellationTokenSource();
            _token     = _cts.Token;

            followersList.InitializationFollowersList(_usersList, "ListOfSharedUsers");

            GetTextFile(_numberLikesDayFileName);
            affixedLikes1.SetNumberLikesDayLabel(_numberLikesDay);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Возвращает список подписчиков пользователя из соц.сети.
        /// TODO: необходимо изменить этот метод по условиям задачи
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="networkType"></param>
        /// <returns></returns>
        ///


        public SocialNetworkUser[] GetSubscribers(String userName, SocialNetwork networkType)
        {
            switch (networkType)
            {
            case SocialNetwork.Twitter:

                TwitterClient tClient   = new TwitterClient();
                long          idTClient = tClient.GetUserIdName(userName);
                return(tClient);

            case SocialNetwork.Instagram:
                InstagramClient iClient = new InstagramClient();
                break;
            }
            return(null);
        }
Exemplo n.º 21
0
        static void LikeTest()
        {
            var username = Credential.GetYourUsername();
            var password = Credential.GetYourPassword();

            var user = new InstagramClient(username, password);

            var loginResult = user.LogIn();

            if (loginResult.authenticated)
            {
                var likeResult = user.Like("1291753606881517996");
                Console.WriteLine(likeResult.status);
            }

            Console.ReadLine();
        }
Exemplo n.º 22
0
        public SubscribedUsers(InstagramClient instagramClient)
        {
            InitializeComponent();

            _instagramClient = instagramClient;

            _mediaLikerList    = new List <MediaLiker>();
            _userFollowersList = new List <InstaUserShort>();

            _userFollowersLoadList = new List <InstagramUser>();
            _subscribedUsersList   = new List <InstagramUser>();
            _likedUsersList        = new List <InstagramUser>();

            ListOfUsersToCheck.InitializationFollowersList(_userFollowersLoadList, "ListOfUsersToCheck");
            ListOfSubscribedUsers.InitializationFollowersList(_subscribedUsersList, "ListOfSubscribedUsers");
            ListOfLikedUsers.InitializationFollowersList(_likedUsersList, "ListOfLikedUsers");
        }
Exemplo n.º 23
0
        public async Task <object> GetPopularMediaAsync()
        {
            string clientId    = "YOUR_CLIENT_ID";
            string accessToken = "A_VALID_ACCESS_TOKEN";

            InstagramClient client = new InstagramClient(clientId, accessToken);

            var popularMedia = await client.MediaEndpoints.GetPopularMediaAsync();

            //I use Json.NET for parsing the result
            var popularMediaJson = JsonConvert.DeserializeObject(popularMedia);

            //You can deserialize json result to one of the models in InstagramCSharp or to your custom model
            //var popularMediaJson = JsonConvert.DeserializeObject<MediaFeed>(popularMedia);

            return(popularMediaJson);
        }
Exemplo n.º 24
0
        public async Task <object> GetRecentTaggedMediaAsync(string tag)
        {
            string clientId     = "YOUR_CLIENT_ID";
            string clientSecret = "YOUR_CLIENT_SECRET";
            string accessToken  = "A_VALID_ACCESS_TOKEN";

            InstagramClient client = new InstagramClient(clientId, clientSecret);

            var recentTaggedMedia = await client.TagEndpoints.GetRecentTaggedMediaAsync(tag, accessToken);

            //I use Json.NET for parsing the result
            var recentTaggedMediaJson = JsonConvert.DeserializeObject(recentTaggedMedia);

            //You can deserialize json result to one of the models in InstagramCSharp or to your custom model
            //var recentTaggedMediaJson = JsonConvert.DeserializeObject<Envelope<List<Media>>>(recentTaggedMedia);

            return(recentTaggedMediaJson);
        }
Exemplo n.º 25
0
        public GeoJson.PointLayer GetPointLayerByBounds(double neLat, double neLng, double swLat, double swLng, int page = 1, string[] ds = null, string[] tags = null)
        {
            string clientId = "db1265f56e574479b72be26cb13aae9b";
            string clientSecret = "1515c3f447094eafa18631f06d16d204";
            string accessToken = "1515c3f447094eafa18631f06d16d204";

            InstagramClient client = new InstagramClient(clientId, "1515c3f447094eafa18631f06d16d204","FRACK - U need to make the user sign in");

            //var popularMedia = await client.MediaEndpoints.GetPopularMediaAsync();

            ////I use Json.NET for parsing the result
            //var popularMediaJson = JsonConvert.DeserializeObject(popularMedia);

            ////You can deserialize json result to one of the models in InstagramCSharp or to your custom model
            ////var popularMediaJson = JsonConvert.DeserializeObject<MediaFeed>(popularMedia);

            //return popularMediaJson;
            return null;
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            //Create RealTime subscription sample

            string clientId     = "YOUR_CLIENT_ID";
            string clientSecret = "YOUR_CLIENT_SECRET";
            string callbackUrl  = "YOUR_CALLBACK_URI";

            InstagramClient instagramClient = new InstagramClient(clientId, clientSecret);

            try
            {
                var responseString  = instagramClient.SubscriptionsEndpoints.CreateUserSubscriptionAsync("YOUR_VERIFY_TOKEN", callbackUrl, RealTimeAspects.Media).Result;
                var newSubscription = JsonConvert.DeserializeObject <Envelope <Subscription> >(responseString);
            }
            catch (Exception ex)
            {
                //Log Exception
            }
        }
Exemplo n.º 27
0
        static void SetUserInfoTest()
        {
            var username = Credential.GetYourUsername();
            var password = Credential.GetYourPassword();

            var user = new InstagramClient(username, password);

            var loginResult = user.LogIn();

            if (loginResult.authenticated)
            {
                var setBioGraphyResult = user.SetBiography("new biography");
                Console.WriteLine(setBioGraphyResult.status);

                var setUsernameResult = user.SetUsername("new username");
                Console.WriteLine(setUsernameResult.status);
            }

            Console.ReadLine();
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            //Create RealTime subscription sample


            string clientId     = "YOUR_CLIENT_ID";
            string clientSecret = "YOUR_CLIENT_SECRET";
            string callbackUrl  = "YOUR_CALLBACK_URI";

            InstagramClient instagramClient = new InstagramClient(clientId, clientSecret, null);

            try
            {
                var response = instagramClient.SubscriptionsEndpoints.CreateGeographySubscriptionAsync("YOUR_VERIFY_TOKEN", callbackUrl, 52.521706, 13.365218, 5000, RealTimeAspects.Media).Result;

                var newSubscription = JsonConvert.DeserializeObject <CreatedSubscription>(response);
            }
            catch (Exception ex)
            {
                //Log Exception
            }
        }
		public async Task Media_Popular()
		{
			var client = new InstagramClient();
			var response = await client.GetPopularMedia();
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Comments_MediaComments()
		{
			var client = new InstagramClient();
			var response = await client.GetCommentsOnMedia("514799749715942011");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Relationship_UserRelationship()
		{
			var client = new InstagramClient();
			var response = await client.GetMyRelationshipWithUser("2175453");
			Assert.AreEqual(200, response.meta.code);
		}
Exemplo n.º 32
0
        public InstaBot()
        {
            InitializeComponent();

            _instagramClient = new InstagramClient();
        }
		public async Task User_UserRecentMedia()
		{
			var client = new InstagramClient();
			var response = await client.GetRecentMediaForUser("185339476");
			Assert.AreEqual(200, response.meta.code);
		}
Exemplo n.º 34
0
        public static void CompleteLogin(string token)
        {
            Token = token;

            InstagramClient = new InstagramClient(token);
        }
		public async Task Tags_TagRecentMedia()
		{
			var client = new InstagramClient();
			var response = await client.GetRecentMediaWithTag("nofilter");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Locations_LocationRecentMedia()
		{
			var client = new InstagramClient();
			var response = await client.GetRecentMediaForLocation("1");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Relationship_UserFollowedBy()
		{
			var client = new InstagramClient();
			var response = await client.GetUsersFollowingGivenUser("185339476");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Locations_Search()
		{
			var client = new InstagramClient();
			var response = await client.SearchLocations(48, 2);
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Relationship_UserRelationship_POST()
		{
			var client = new InstagramClient();
			var response = await client.ChangeMyRelationshipWithUser("2175453", RelationshipAction.follow);
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Media_Shortcode()
		{
			var client = new InstagramClient();
			var response = await client.GetMediaFromShortcode("D");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task User_Search()
		{
			var client = new InstagramClient();
			var response = await client.SearchTags("cambloom");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task User_UserRecentMedia_WithToken()
		{
			var client = new InstagramClient();
			var response = await client.GetRecentMediaForUser("2175453");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Locations_SearchFoursqare()
		{
			var client = new InstagramClient();
			var response = await client.SearchLocationsNearFoursquarePlace("4ab7e57cf964a5205f7b20e3");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Likes_MediaLike_DELETE()
		{
			var client = new InstagramClient();
			var response = await client.UnlikeMedia("514799749715942011");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task User_SelfLikedMedia()
		{
			var client = new InstagramClient();
			var response = await client.GetMediaILiked();
			Assert.AreEqual(200, response.meta.code);
		}
Exemplo n.º 46
0
 /// <summary>
 /// Initializes a new instance of the login form with a specified OAuth client.
 /// </summary>
 /// <param name="client">Instance of the OAuth client.</param>
 /// <param name="autoLogout">Disables saving and restoring authorization cookies in WebBrowser. Default: false.</param>
 /// <param name="loadUserInfo">Indicates the need to make a request for recive the user profile or not. Default: false.</param>
 /// <param name="responseType">Allows to set the type of response that is expected from the server. Default: <see cref="ResponseType.Token"/>.</param>
 public InstagramLogin(InstagramClient client, bool autoLogout = false, bool loadUserInfo = false, string responseType = "token") : base(client, autoLogout, loadUserInfo, responseType)
 {
     this.Icon = Properties.Resources.instagram;
 }
		public async Task User_User()
		{
			var client = new InstagramClient();
			var response = await client.GetUserInfo("2175453");
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Relationship_SelfRequestedBy()
		{
			var client = new InstagramClient();
			var response = await client.GetMyPendingRelationships();
			Assert.AreEqual(200, response.meta.code);
		}
		public async Task Locations_SearchFacebookPlaces()
		{
			var client = new InstagramClient();
			var response = await client.SearchLocationsNearFacebookPlace("91641530652");
			Assert.AreEqual(200, response.meta.code);
		}