유튜브 api 사용하기
데모
<?php
//ver1.0 150423 @_untitle_d
$yt_api = ''; //유튜브 API KEY, https://console.developers.google.com/project
function get_video_id($url){}
function youtube_info($id, $part='snippet')
{
global $yt_api;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://www.googleapis.com/youtube/v3/videos?id={$id}&key={$yt_api}&part={$part}");
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($curl);
curl_close($curl);
return json_decode($return, true);
}
$tmp_yt = 'http://www.youtube.com/watch?v=yEJ2-VofNCw'; //유튜브 동영상
$return = youtube_info(get_video_id($tmp_yt)); //유튜브 정보
echo "동영상 : ".$tmp_yt."<br>";
echo "제목 : ".$return['items'][0]['snippet']['title']."<br>"; //title
echo "채널명 : ".$return['items'][0]['snippet']['channelTitle']."<br>"; //channelTitle
echo "썸네일 : <img src='".$return['items'][0]['snippet']['thumbnails']['default']['url']."'><br>"; //thumb default
print_r($return);
?>
관련링크
http://untitled.untitle311apyxry1w48.com/lkbmgfh
참고
게시글 목록
| 번호 | 제목 |
|---|---|
| 11832 |
jQuery
remove()를 이용하여 엘리먼트 삭제하기
|
| 11829 | |
| 11826 |
jQuery
동일 엘리먼트 순번 알아내기
2
|
| 11823 | |
| 11822 | |
| 11821 | |
| 11820 |
jQuery
position() 메서드 객체에 대한 좌표값
|
| 11819 | |
| 20318 | |
| 11818 | |
| 11817 | |
| 11816 | |
| 11814 | |
| 11813 | |
| 11811 | |
| 11810 |
jQuery
class가 있는지 없는지 체크하기
|
| 11809 |
PHP
배열에서 중복 값 없애기
|
| 11808 | |
| 11807 |
JavaScript
str_pad 자릿수만큼 특정문자로 채우기
|
| 11806 | |
| 11805 | |
| 11804 | |
| 11803 | |
| 11802 | |
| 11801 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기