1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?php // Je recherche les video Youtube
$video_title = $basic['title']->value;
$trouve3=true;
if ($video_title != '' && $basic['support']->value == "Vidéo")
{
$search_youtube =file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet®ionCode=fr&maxResults=25&q=".urlencode($video_title)."&key=AIzaSyAuz");
$search_youtubej =json_decode($search_youtube,true);
if( !empty($search_youtubej['items']) )
{
foreach ($search_youtubej['items'] as $item)
{
$youtubeTitle = $item['snippet']['title'];
if(stristr($youtubeTitle,'bande annonce')||strstr($youtubeTitle,'bande-annonce'))
{
$trouve3=true;
$youtubeID = $item['id']['videoId'];
$youtubeDescription = $item['snippet']['description'];
break;
} else {
$trouve3=false;
}
}
}
} |