2014-02-25 2 views
0

YouTube에서 브라우저 기반 비디오를 업로드하려고합니다. 인터넷에서이 코드를 얻었습니다. 이 자습서에서. Youtube API - 채널에 비디오를 업로드하려면 YouTube 로그인 암호가 필요합니까?

http://www.rd2inc.com/blog/2012/08/youtube-browser-based-uploader-with-php/

이제 질문은 : 내가 개발자 키를 사용할 때 이유는, YouTube 비밀번호가 필요합니까?

$ youtube_email = ""; // 이메일 주소를 youtube로 변경하십시오. $ youtube_password = ""; // 이것을 youtube 로그인 암호로 변경하십시오. // 개발자 키 : 여기에 키를 가져 오기 : http://code.google.com/apis/youtube/dashboard/. $ key = "";

$source = ''; // A short string that identifies your application for logging purposes. 
$postdata = "Email=".$youtube_email."&Passwd=".$youtube_password."&service=youtube&source=" . $source; 
$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)); 

$youtube_video_title = $video_title; // This is the uploading video title. 
$youtube_video_description = $video_description; // This is the uploading video description. 
$youtube_video_keywords = "demo"; // This is the uploading video keywords. 
$youtube_video_category = "Tech"; 

답변

관련 문제