메뉴 건너뛰기

프로그램언어

조회 수 1140 추천 수 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">

 


  1. PHP와 HTML과 자바스크립트의 관계

    Date2021.03.26 Views311
    Read More
  2. TIFF, GIF 여러장 변환

    Date2021.03.26 Views323
    Read More
  3. 정규표현식

    Date2021.03.26 Views311
    Read More
  4. date() 함수의 출력 형식

    Date2021.03.26 Views241
    Read More
  5. 확장자 추출 하기

    Date2021.03.26 Views309
    Read More
  6. 서브도메인 세션 공유

    Date2021.03.26 Views537
    Read More
  7. 가변변수로 만든 배열

    Date2021.03.26 Views272
    Read More
  8. HEREDOC <<< ( PHP에서 echo로 HTML쉽게 표시하기 )

    Date2021.03.26 Views371
    Read More
  9. 배열 연산자 []= 에 대해서

    Date2021.03.26 Views231
    Read More
  10. Predefined Variables (미리 정의된 변수들)

    Date2021.03.26 Views274
    Read More
  11. current() next() key() 그외 배열관련 함수

    Date2021.03.26 Views253
    Read More
  12. 비교연산자 ( === 에 관해서 )

    Date2021.03.25 Views307
    Read More
  13. 큰따옴표(") 와 작은따옴표(')

    Date2021.03.25 Views270
    Read More
  14. mysql_free_result(); 관련 오류

    Date2021.03.25 Views288
    Read More
  15. phpMyAdmin WebMysql 에 CSV 엑셀 파일 업로드 입력하기 ( Excel / Upload / data / 데이터 / 데이타 )

    Date2021.03.25 Views760
    Read More
  16. PHP + 유튜브(youtube) 동영상 업로드 연동 소스

    Date2021.01.21 Views1140
    Read More
  17. 다중파일 업로드 + 이미지 미리보기 (Javascript, jQuery )

    Date2020.12.15 Views912
    Read More
  18. 경로 제외한 파일 이름만 선택하는 방법, Basename()

    Date2020.11.23 Views429
    Read More
  19. 쿠키 확인 후 만료시 세션 파괴하는 방법

    Date2020.11.23 Views314
    Read More
  20. DAUM 지도 API 좌표→주소(주소->좌표) 변환

    Date2020.10.05 Views431
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved