$key="AIzaXXXX";
$JSONComent = file_get_contents("https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&videoId=".$idVideo."&key=".$key);
$JSONComent = json_decode($JSONComent);
$arrComents = array();
foreach ($JSONComent->items as $clave=>$valor) {
$arrAux = array();
$arrAux["id"] = $valor->snippet->topLevelComment->id;
$arrAux["textDisplay"] = $valor->snippet->topLevelComment->snippet->textDisplay;
$arrAux["publishedAt"] = $valor->snippet->topLevelComment->snippet->publishedAt;
$arrAux["authorDisplayName"] = $valor->snippet->topLevelComment->snippet->authorDisplayName;
$arrAux["authorProfileImageUrl"] = $valor->snippet->topLevelComment->snippet->authorProfileImageUrl;
$arrAux["mainComent"] = 1;
$arrComents[] = $arrAux;
if (isset($valor->replies->comments)) {
$total = count($valor->replies->comments);
for ($i=0;$i<$total;$i++) {
$arrAux = array();
$arrAux["id"] = $valor->replies->comments[$i]->id;
$arrAux["textDisplay"] = $valor->replies->comments[$i]->snippet->textDisplay;
$arrAux["publishedAt"] = $valor->replies->comments[$i]->snippet->publishedAt;
$arrAux["authorDisplayName"] = $valor->replies->comments[$i]->snippet->authorDisplayName;
$arrAux["authorProfileImageUrl"] = $valor->replies->comments[$i]->snippet->authorProfileImageUrl;
$arrAux["mainComent"] = 0;
$arrComents[] = $arrAux;
}
}
$JSONAux = file_get_contents("https://www.googleapis.com/youtube/v3/commentThreads?key=".$key."&part=id,snippet,replies&id=".$valor->id);
$JSONAux = json_decode($JSONAux);
if (isset($JSONAux->items[0]->replies)) {
foreach ($JSONAux->items[0]->replies as $claveAux=>$valorAux) {
$total = count($valorAux);
for ($i=0;$i<$total;$i++) {
$yaEsta = false;
$totArrComent = count($arrComents);
for ($k=0;$k<$totArrComent;$k++) {
if ($arrComents[$k]["id"] == $valorAux[$i]->id) {
$yaEsta = true;
}
}
if (!$yaEsta) {
$arrAux = array();
$arrAux["id"] = $valorAux[$i]->id;
$arrAux["textDisplay"] = $valorAux[$i]->snippet->textDisplay;
$arrAux["publishedAt"] = $valorAux[$i]->snippet->publishedAt;
$arrAux["authorDisplayName"] = $valorAux[$i]->snippet->authorDisplayName;
$arrAux["authorProfileImageUrl"] = $valorAux[$i]->snippet->authorProfileImageUrl;
$arrAux["mainComent"] = 0;
$arrComents[] = $arrAux;
}
}
}
}
} // foreach
API YouTube: Obtener todos los comentarios (Enero/2022)
Suscribirse a:
Enviar comentarios (Atom)
The best and newest casino site | Choctaw Casino Resort
ResponderEliminarChoctaw Casino Resort 1xbet offers the latest in gaming and dining, as 메리트 카지노 쿠폰 well as an online casino, poker room, bingo, live entertainment, 카지노 luxury hotel, spa and