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:
- Contoh Penggunaan CURL Untuk Grab Video Youtube Api v3 Part 1
- WikiDefinition, Wiki Definition Php Function
- Menghapus Karakter Tertentu Dengan PHP Bagaimana Menghapus Simbol-Simbol
0 Response to "Grab Youtube Php API V3"
Posting Komentar