Grab Youtube Php API V3, menggunakan curl tentu sangat membantu dalam grab sebuah website. Implementasinya akan dibahas pada web sedot code.
Baca juga:
function ngegrab($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$uaa = $_SERVER['HTTP_USER_AGENT'];
curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: $uaa");
return curl_exec($ch);
}
function search_video_ytb($kw,$api,$num='5'){
$kw = urlencode($kw);
$grab = ngegrab('https://www.googleapis.com/youtube/v3/search?key=' . $api . '&part=snippet&order=relevance&maxResults='.$num.'&q=' . $kw . '&type=video');
$json = json_decode($grab);
return $json;
}
function detail_video_ytb($api,$idvideo){
return ngegrab('https://www.googleapis.com/youtube/v3/videos?key=' . $api . '&part=contentDetails,statistics&id=' . $idvideo . '');
}
Baca juga:
Load disqus comments
0 komentar