public void SearchFile(InstamgramClient instamgramClient, Action <ImageInfo> searchResult)
        {
            if (instamgramClient == null)
            {
                return;
            }
            NetClient netClient   = new NetClient();
            string    currentPath = "/users/self/media/recent/";
            string    currentHost = "api.instagram.com/v1";
            string    photoList   = instamgramClient.SearchCurrent(currentHost, currentPath);

            if (!string.IsNullOrEmpty(photoList))
            {
                InstagramBeans instagramBeans = JsonConvert.DeserializeObject <InstagramBeans>(photoList);
                if (instagramBeans != null && instagramBeans.data != null)
                {
                    foreach (var image in instagramBeans.data)
                    {
                        if (image.images != null && image.images.ContainsKey("standard_resolution"))
                        {
                            int       width     = int.Parse(image.images["standard_resolution"]["width"]);
                            int       height    = int.Parse(image.images["standard_resolution"]["height"]);
                            string    url       = image.images["standard_resolution"]["url"];
                            ImageInfo imageInfo = new ImageInfo()
                            {
                                Width  = width,
                                Height = height,
                                Url    = url
                            };
                            searchResult?.Invoke(imageInfo);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        // GET: /Home/Connect
        public async Task <InstamgramClient> GetInstagramClient()
        {
            Oauth2Helper oauth2Helper = new Oauth2Helper()
            {
                ClientId      = _clientId,
                Secret        = _secret,
                RedirectUrl   = _redirectUri,
                CodeEndPoint  = _codeEndPoint,
                TokenEndPoint = _tokenRequestURI,
                SuccessUrl    = _successUrl,
                SucessMsg     = _msg
            };
            var userCredential = await oauth2Helper.GetUserCredential();

            InstamgramClient instamgramClient = new InstamgramClient(userCredential);

            return(instamgramClient);
        }