| Server IP : 162.214.74.102 / Your IP : 216.73.216.192 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/google/ |
Upload File : |
<?php
include_once __DIR__ . "/Google.php";
class GoogleYoutube extends Google
{
protected $api_key_youtube = 'AIzaSyC0vUVt5Cy1kR1mP0BmRf94EBXS4_odsi0';
public function __construct()
{
// Incluído para não carregar o construct do Pai
}
/*
* Função para buscar o JSON com dados do vídeo na API do Google Youtube
*/
public function getVideoInfo($param)
{
$id = "";
if(strpos($param, 'youtube.com') > 0){
parse_str(parse_url($param, PHP_URL_QUERY), $urlParams);
if(!empty($urlParams['v'])){
$id = $urlParams['v'];
}
} else if(strpos($param, 'youtu.be') > 0){
$urlPath = parse_url($param, PHP_URL_PATH);
$id = substr($urlPath, 1);
} else {
$id = $param;
}
$url = "https://youtube.googleapis.com/youtube/v3/videos" .
"?key=" . $this->api_key_youtube .
"&id=" . $id .
"&part=id,snippet,contentDetails";
$json_google = curl_init($url);
curl_setopt($json_google, CURLOPT_RETURNTRANSFER, true);
$json_response = curl_exec($json_google);
$result = json_decode($json_response);
if(!isset($result->items))
{
var_dump($result);
echo '%%%%%%%%%%%%%%%%% ERRO DE CONEXÃO COM API DO GOOGLE YOUTUBE %%%%%%%%%%%%%%\n\n\n';
exit;
}
else if (count($result->items) > 0)
{
return $result->items[0];
}
else
{
return false;
}
}
}