Buongiorno.
Da questa mattina il mio sito non carica più video youtube e il problema è questo passaggio alla V3 che dovrebbe scadere a fine mese.
Il mio codice era il seguente
Codice per il recupero di 1 video in base ad una parola chiave (che in questo caso era contenuta nella variabile $vq)
codice:
<?php
$i=1;
$feedURL = "http://gdata.youtube.com/feeds/api/videos?vq=$vq&orderby=relevance&start-index=1&max-results=1";
$sxml = simplexml_load_file($feedURL);
// iterate over entries in feed
foreach ($sxml->entry as $entry) {
// get nodes in media: namespace for media information
$media = $entry->children('http://search.yahoo.com/mrss/');
// get video player URL
$attrs = $media->group->player->attributes();
$watch = $attrs['url'];
// get video thumbnail
$attrs = $media->group->thumbnail[0]->attributes();
$thumbnail = $attrs['url'];
// get <yt:duration> node for video length
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
// get <gd:rating> node for video ratings
$gd = $entry->children('http://schemas.google.com/g/2005');
if ($gd->rating) {
$attrs = $gd->rating->attributes();
$rating = $attrs['average'];
} else {
$rating = 0;
}
$id = split('/?v=', $watch);
$ytu=$id[1];
$ytu_toadd=str_replace("&feature=youtube_gdata_player", "", $ytu);
$title= $media->group->title;
$desc=$media->group->description;
$duration_formatted=gmdate("i:s", "$length");
} // end for each
?>
Codice di visualizzazione del video estratto
codice:
<!-- 1. The <iframe> (and video player) will replace this <div> tag. --> <div id="player"></div>
<script>
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '<?=$ytu_toadd?>',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
</script>
Credo il problema sia nella prima parte di codice, visto che la seconda è un semplice "player". Potete darmi dei suggerimenti su come poter recuperare un video da una data keyword e salvare il codice per poi poterlo visualizzare ?
Qualsiasi suggerimento va bene.
Grazie a tutti.