<?php
include_once('../../../common.php');


$g5['title'] = "YOUTUBE";
$page_class = "01";

include_once(G5_THEME_PATH.'/page/head.php');

//유튭 DB에서 가져오기. 하루에 한번만 api 호출
$q = "SELECT * FROM `youtube_data` WHERE `reg_date` = '".date('Ymd')."'";
$yd = sql_fetch($q);

if(!$yd['datas']){
	//youtube데이터 가져오기
	$api_key = 'AIzaSyAYYg2RDRavDZtBSzV-QKRUCOO0VeaFmZA';
	$channel_id = 'UCMAC9PA8dMvvxIiM0vp8XYA';
	$channel_id = 'UC0v-d8dLhB-tAZuAIW3ZZIg';
	// YouTube Data API 엔드포인트
	$api_url = "https://www.googleapis.com/youtube/v3/search?key=$api_key&channelId=$channel_id&order=date&part=snippet&type=video&maxResults=6";
	$youtube_data = '';

	$ch = curl_init($api_url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($ch);
	curl_close($ch);

	$q = "INSERT INTO `youtube_data` SET datas = '".$response."', `reg_date` = '".date('Ymd')."'";
	sql_query($q);

	//$wr_id = sql_insert_id();
	$q = "SELECT * FROM `youtube_data` WHERE `reg_date` = '".date('Ymd')."'";
	$yd = sql_fetch($q);
}

$youtube_data = json_decode($yd['datas']);
?>


<!-- lnb -->
<div class="lnb_wrap">
    <div class="lnb">
        <ul>
            <li><a href="/company_news"><span>Company News</span></a></li>
            <li><a href="/meet"><span>Meet our Innovator</span></a></li>
            <li><a href="/page/media/sns/instagram.php"><span class="on">SNS</span></a></li>                             
        </ul>
    </div>
</div>
<!-- lnb -->


<main class="site-wrapper">
    <style>
    .snb .stick_ {position: fixed;top: 75px;z-index: 10;width: 100%;background: #fff;-webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03);box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03);}
    @media only screen and (max-width: 767.98px) {
        .snb .stick_ {top:68px;}
    }

	.img_hv img{width:350px;height:auto;max-height:350px;}
    </style>
    <!-- snb -->
    <div id="snb_wrap">
        <div class="snb">            
            <ul class="stick stick_">
                <li><a href="/page/media/sns/instagram.php" class="on">Instagram</a></li>
                <li><a href="/page/media/sns/youtube.php" class="on text-brand-color">Youtube</a></li>
                <li><a href="/page/media/sns/linked_in.php" class="on">Linked In</a></li>                
                <li><a href="#end" class="on"></a></li>                                                         
            </ul>
        </div>            
    </div>
    <!-- snb -->

    <div class="sm-top padding-five-top md-padding-ten-top">
        <div class="container">
            <div class="row margin-two-bottom">
                <div class="col-lg-5 margin-four-bottom overlap-left-1">       
                    <h1 class="text-black font-weight-700 mb-20 mb-md-20 mb-sm-10">Youtube<br>&nbsp</h1>
                    <p class="text-brand-color font-weight-700">
                        Media <i class="xi-angle-right-min position-relative top-2"></i> SNS
                    </p>
                </div>
                <div class="col-lg-7 lg-margin-ten-bottom">   
                    <p class="text-extra-large text-black mb-10">
                        <strong>
                            Follow us
                        </strong>
                    </p>           
                    <span class="text-black font-weight-500">
                        @ajinomotocellistkorea
                    </span>                            
                    <p class="text-black font-weight-500">
                        아지노모도셀리스트코리아의 최신 소식을 SNS에서 확인해보세요.
                    </p>                       
                    <div class="text-left">
                        <a href="https://www.youtube.com/@ajinomotocellistkorea" target="_blank" class="text-medium btn_1 btn-brand1">
                            Youtube <i class="xi-angle-right"></i>
                        </a> 
                    </div>                  
                </div>                
            </div>
        </div>
    </div>








    <div class="padding-six-top md-padding-twenty-top sp-bottom bg-light-gray">
        <div class="container">

            <div id="ytt" class="row img_list">
                <!--<div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.0s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>
                <div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.2s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>
                <div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.4s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>
                <div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.0s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>
                <div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.2s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>
                <div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.4s">
                    <div class="img_hv">
                        <a href="#">
                            <img src="https://via.placeholder.com/1080x1080">
                        </a>
                    </div>                                            
                </div>-->
            </div>

        </div>
    </div>



</main>

<!-- sec - end -->
<div id="end" class="row sec"></div>

<script type="text/javascript">	
	//유튭
	var yt = <?php echo json_encode($youtube_data);?>;
	var yti = yt.items;
	var ytt = '';//유튭 탭에 노출될 태그
	//console.log(yti);
	for(var i=0; i<yti.length;i++){
		ytt += '<div class="col-xg-4 col-lg-4 col-md-6 col-sm-6 wow fadeInUp" data-wow-delay="0.0s"><div class="img_hv"><a href="https://www.youtube.com/watch?v='+yti[i].id.videoId+'" target="_blank"><img title="'+yti[i].snippet.title+'" src="'+yti[i].snippet.thumbnails.high.url+'"></a></div></div>';
		//ytt += '<div class="col-xg-4 col-lg-4 col-md-6 col-sm-6"><div class="img_hv"><a href="https://www.youtube.com/watch?v='+yti[i].id.videoId+'" target="_blank"><img title="'+yti[i].snippet.title+'" src="'+yti[i].snippet.thumbnails.high.url+'"></a></div></div>';
		//console.log(yti[i]);
	}

	$('#ytt').html(ytt);//유튜브탭
	console.log(yt);
</script>
	




<?php
include_once(G5_PATH.'/tail.php');


