Exemple #1
0
        private void ProcSearchNaverApi(string movieName)
        {
            string clientID     = "ZrW5YejTfOktXlA19v1H";
            string clientSecret = "qX4dunM8w8";
            string openApiUrl   = $"https://openapi.naver.com/v1/search/movie?start=1&display=30&query={movieName}";

            string resJson    = Commons.GetOpenApiResult(openApiUrl, clientID, clientSecret);
            var    parsedJson = JObject.Parse(resJson);

            int total   = Convert.ToInt32(parsedJson["total"]);
            int display = Convert.ToInt32(parsedJson["display"]);

            StsResult.Content = $"{total} 중 {display} 호출 성공";

            var items      = parsedJson["items"];
            var json_array = (JArray)items;

            List <Movieitem> movieItems = new List <Movieitem>();

            foreach (var item in json_array)
            {
                Movieitem movie = new Movieitem(
                    Commons.StripHtmlTag(item["title"].ToString()),
                    item["link"].ToString(),
                    item["image"].ToString(),
                    item["subtitle"].ToString(),
                    item["pubDate"].ToString(),
                    Commons.StripPipe(item["director"].ToString()),
                    Commons.StripPipe(item["actor"].ToString()),
                    item["userRating"].ToString());
                movieItems.Add(movie);
            }

            this.DataContext = movieItems;
        }
Exemple #2
0
        private void ProcSearchNaverApi(string movieName)
        {
            string clientID     = "kZwov3BYbBv2fCrJKz4Y";
            string clientSecret = "RykwuCjDVG";
            string openApiUrl   = $"https://openapi.naver.com/v1/search/movie?start=1&display=30&query={movieName}";

            string resJson    = Commons.GetOpenApiResult(openApiUrl, clientID, clientSecret);
            var    parsedJson = JObject.Parse(resJson);

            int total   = Convert.ToInt32(parsedJson["total"]);
            int display = Convert.ToInt32(parsedJson["display"]);

            StsResult.Content = $"{total} 중 {display} 호출 성공";

            var items      = parsedJson["items"];
            var json_array = (JArray)items;

            List <MovieItem> movieItems = new List <MovieItem>();

            foreach (var item in json_array)
            {
                MovieItem movie = new MovieItem(
                    Commons.StringHtmlTag(item["title"].ToString()),
                    item["link"].ToString(),
                    item["image"].ToString(),
                    item["subtitle"].ToString(),
                    item["pubDate"].ToString(),
                    Commons.StripPipe(item["director"].ToString()),
                    Commons.StripPipe(item["actor"].ToString()),
                    item["userRating"].ToString());
                movieItems.Add(movie);
            }

            this.DataContext = movieItems;

            //List<NaverFavoriteMovies> list = new List<NaverFavoriteMovies>();

            //foreach (MovieItem item in GrdData.SelectedItems)
            //{
            //    NaverFavoriteMovies temp = new NaverFavoriteMovies()
            //    {
            //        Title = item.Title,
            //        Link = item.Link,
            //        Image = item.Image,
            //        SubTitle = item.SubTitle,
            //        PubDate = item.PubDate,
            //        Director = item.Director,
            //        Actor = item.Actor,
            //        UserRating = item.UserRating,
            //        RegDate = DateTime.Now
            //    };

            //    list.Add(temp);
            //}
        }
Exemple #3
0
        /*Naver API 사용을 위한 사용자 정보입력 부분*/
        private void PorcSearchNaverApi(string movieName)
        {
            // API 호츨
            string clientID     = "kOQI3W4J8QmJV8UukmBZ";   // 발급받은 API 아이디
            string clientSecret = "e9EjOaik91";             // 발급받은 API 비밀번호
            string openApiUrl   = $"https://openapi.naver.com/v1/search/movie?start=1&display=30&query={movieName}";

            string  resJson    = Commons.GetOpenApiResult(openApiUrl, clientID, clientSecret);
            JObject parsedJson = JObject.Parse(resJson);    // API 에서 발급받은 정보(string)를 JSON으로 파싱

            int total   = Convert.ToInt32(parsedJson["total"]);
            int display = Convert.ToInt32(parsedJson["display"]);

            StsResult.Content = $"{total} 중 {display} 호출 성공";

            JToken items      = parsedJson["items"];
            JArray json_array = (JArray)items;

            List <MovieItem> movieItems = new List <MovieItem>(); // API에서 불러온 데이터들을 저장할 리스트 선언

            foreach (var item in json_array)
            {
                MovieItem movie = new MovieItem(
                    Commons.StripHtmlTag(item["title"].ToString()),
                    item["link"].ToString(),
                    item["image"].ToString(),
                    item["subtitle"].ToString(),
                    item["pubDate"].ToString(),
                    Commons.StripPipe(item["director"].ToString()),
                    Commons.StripPipe(item["actor"].ToString()),
                    item["userRating"].ToString());
                movieItems.Add(movie);
            }

            this.DataContext = movieItems;      // 그리드에 데이터 바인딩
        }