메뉴 건너뛰기

프로그램언어

조회 수 1135 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<form method="post" name="form1">
<input type="hidden" name="ucc_url">
제목 : <input style="WIDTH: 500px" maxlength="100" name="title">
영상첨부 : <div onclick="youtube_open();" class="btn_100">동영상 첨부</div>
</form>
<div><input onclick="check_in();" type="button" value="글저장"></div>
<form method="post" name="form2">
<input type="hidden" name="title">
</form>
<script language="javascript">
    function youtube_open(){
        if(document.form1.title.value==''){
            alert('제목을 먼저 입력해주세요.\n유튜브 영상에 표시될 제목입니다.');
            document.form1.title.focus();
            return;
        }
        f = document.form2;
         window.open('','youtPop','width=400,height=300');
         f.target = 'youtPop';
         f.action = 'youtube_upload.php';
         f.title.value=document.form1.title.value;
         f.submit();
    }
                
               function check_in(){
                  if(document.form1.ucc_url.value==''){
                     alert('영상을 첨부해주세요.');
                     return;
                  }
                  document.form1.action='ok.php';
                  document.form1.submit();
              }
</script>
 

 

youtube_upload.php

<!--?php
$youtube_email = "유튜브 로그인 아이디"; // Change this to your youtube sign in email.
$youtube_password = "유튜브 로그인 패스워드"; // Change this to your youtube sign in password.
  
$postdata = "Email=".$youtube_email."&Passwd=".$youtube_password."&service=youtube&source=Example";
$curl = curl_init("https://www.google.com/youtube/accounts/ClientLogin");
curl_setopt($curl, CURLOPT_HEADER, "Content-Type:application/x-www-form-urlencoded");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
$response = curl_exec($curl);
curl_close($curl);
  
list($auth, $youtubeuser) = explode("\n", $response);
list($authlabel, $authvalue) = array_map("trim", explode("=", $auth));
list($youtubeuserlabel, $youtubeuservalue) = array_map("trim", explode("=", $youtubeuser));
  
 $_REQUEST['title'] = iconv("euc-kr", "utf-8", $_REQUEST['title']);  // 외국 자료 원본소스에서 한글처리 때문에 추가
  
$youtube_video_title = $_REQUEST['title']; // This is the uploading video title.
$youtube_video_description = $_REQUEST['title']; // This is the uploading video description.
$youtube_video_category = "Entertainment"; // This is the uploading video category.   //카테고리는 정책적으로 지정된것중에서만 써야되는듯...
$youtube_video_keywords = $_REQUEST['title']; // This is the uploading video keywords.
  
$data = '<?xml version="1.0"?-->
            <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">
              <media:group>
                <media:title type="plain">'.$youtube_video_title.'</media:title>
                <!--?xml:namespace prefix = "media" /--><media:description type="plain">'.$youtube_video_description.'</media:description>
                <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">'.$youtube_video_category.'</media:category>
                <media:keywords>'.$youtube_video_keywords.'</media:keywords>
               
            </media:group></entry>';
  
$key = "발급받은 유튜브 개발자 키"; // Get your key here: http://code.google.com/apis/youtube/dashboard/.
  
$headers = array("Authorization: GoogleLogin auth=".$authvalue,
                 "GData-Version: 2",
                 "X-GData-Key: key=".$key,
                 "Content-length: ".strlen($data),
                 "Content-Type: application/atom+xml; charset=UTF-8");
  
$curl = curl_init("http://gdata.youtube.com/action/GetUploadToken");
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_REFERER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
  
$response = simplexml_load_string(curl_exec($curl));
curl_close($curl);
?>
<!--?php
$nexturl = "리턴값을 받을 페이지 풀url..여기서는 일단 http://도메인/upload_ok.php"; // This parameter specifies the URL to which YouTube will redirect the user's browser when the user uploads his video file.
?-->
 
 
 
 
<SCRIPT type=text/javascript>
  function checkForFile() {
    if (document.form_y.file.value!=='') {
        document.form_y.submit();
    }else{
        alert('영상을 첨부해주세요.');
    }
  }
</SCRIPT>
 
 
<form enctype="multipart/form-data" method="post" name="form_y" action="<?php echo($response->url); ?>?nexturl=<?php echo(urlencode($nexturl)); ?>">
  파일 : <input id="file" type="file" name="file">
  제목 : <!--? echo($youtube_video_title); ?-->
  <input type="hidden" value="<?php echo($response->token); ?>" name="token">
  <input onclick="checkForFile();" type="button" value="유튜브로 전송">
</form>
※ 업로드창이 자동으로 닫힐 때까지 창을 닫지 마세요.
※ 업로드가 완료되면 이 창은 자동으로 닫힙니다.
 

 

 

<!--?
    $ucc_url = $_REQUEST["id"];
    $ucc_status = $_REQUEST["status"];
     
    if($ucc_status == "200"){
?-->
        <SCRIPT language=javascript>
        <!--
            opener.document.form1.ucc_url.value='<?=$ucc_url?>';
            window.close();
        //-->
        </SCRIPT>
<!--?
    }else{
?-->
        <SCRIPT language=javascript>
        <!--
            alert("실패");
            window.close();
        //-->
        </SCRIPT>
<!--?
    }  
?-->

 

썸네일소스

<iframe width="640" height="360" src="https://www.youtube.com/embed/<!--?=$ucc_url?-->" frameborder="0" allowfullscreen></iframe>
<img src="http://i2.ytimg.com/vi/%3C?=$ucc_url?>/default.jpg">

 


List of Articles
번호 제목 날짜 조회 수
340 환경변수 HTTP_USER_AGENT를 이용해서 스마트 기기 분류하기 2016.09.21 25959
339 확장자 추출 하기 2021.03.26 308
338 홈페이지 귀퉁이에 붙이는 공지창 file 2015.04.06 25426
337 헤더이용 다운로드 받을시 바로열기부분 소스 2018.07.24 7320
336 해당하는 날짜가 그달의 몇주째인지 계산 2014.02.27 26351
335 함수이름을 변수로 사용하기, 매개변수 없는 함수에 매개변수 넣기 2021.03.26 746
334 한글줄바꾸기 또는 utf-8 wordwrap 2014.04.12 26546
333 한글자르기 substr 2015.04.14 25198
332 한글이 깨져서 나올 때 - iconv 2018.08.29 3933
331 필드값 저장 2014.02.27 24276
330 프레임 사이트에서 새로고침(F5) 할때 초기화면으로 이동하지 않음 2019.01.08 1280
329 폴더에 사진올려놓고 리스트자동으로 만들기 2019.01.08 1302
328 폴더 용량 체크 2023.01.12 216
327 포트체크 방법 2019.01.16 1288
326 페이지 로딩 시간 측정 2014.02.27 26041
325 파일을 변수에 담기(ob_start를 이용한 방법) 2021.03.26 674
324 파일업로드 2017.02.19 19352
323 파일시스템, 폼 파일업로드 관련 함수 2017.03.27 21681
322 파일 확장자 비교 2016.12.23 21970
321 파일 종류에 따른 아이콘표시하기 함수 2019.01.16 1421
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved