Ler mais" />

Storie Plus Plugin – videos.php

O código abaixo faz parte do código do plugin Storie Plus Plugin, correspondente ao arquivo: Storie Plus Plugin/storieplus_plugin/videos.php

<?php echo '<body style="background-color:#1C1C1C;">'; // Chave da API do YouTube $api_key = "AIzaSyB539TNJqHic6f30hkJULfTuysbDzj2gao"; // ID da playlist do YouTube $playlist_id = "PLg-3LrJCBQMrfu9-aJ8wcFjEXYCj3YNPy"; // URL da API com os parâmetros de busca $url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=" . $playlist_id . "&key=" . $api_key . "&status=public"; // Faz a requisição HTTP para a API do YouTube $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => false )); $response = curl_exec($curl); curl_close($curl); // Converte a resposta em um array associativo $data = json_decode($response, true); // Verifica se há vídeos disponíveis if (isset($data["items"]) && !empty($data["items"])) { // Cria a tabela com os dados da playlist echo "<div style='display: flex; justify-content: center; align-items: center;'>"; echo "<table style='border-collapse: collapse; width: 60%; margin-top: 20px; padding: 20px;'>"; echo "<thead style='background-color: #333; color: #fff;'>"; echo "<tr><th style='padding: 12px; color: #fff;'>Veja todas as aulas abaixo</th><th style='padding: 0px; color: #fff;'>Link do Vídeo</th></tr>"; echo "</thead>"; echo "<tbody>"; foreach ($data["items"] as $item) { $title = $item["snippet"]["title"]; $video_id = $item["snippet"]["resourceId"]["videoId"]; $video_url = "https://www.youtube.com/watch?v=" . $video_id; echo "<tr><td style='border: 1px solid #ccc; padding: 12px; color: white;'>" . $title . "</td><td style='border: 1px solid #ccc; padding: 12px;text-align: center;'><button style='background-color: #2F4F4F; color: #fff; padding: 10px 20px; border-radius: 5px; text-decoration: none; transition: background-color 0.5s;' onclick="window.open('".$video_url."', '_blank')">VER AGORA</button></td></tr>"; } echo "</tbody>"; echo "</table>"; echo "</div>"; } else { // Mostra mensagem caso não haja vídeos disponíveis echo "<p style='text-align: center; margin-top: 20px; color: #fff;'>Não há vídeos disponíveis no momento.</p>"; } echo "<p style='text-align: center; margin-top: 20px; color: #fff;'>Desenvolvido por: <a href='https://www.instagram.com/ezequielsantossas/' target='_blank' style='color: #fff;'>Ezequiel Sas</a> e<a href='https://instagram.com/izalmosilva' target='_blank' style='color: #fff;'> Izalmo Silva</a>.</p>"; ?>

Você pode baixar o plugin wordpress: Storie Plus Plugin, clicando no link a seguir: https://wordpress.org

Explicação do código do Plugin: Storie Plus Plugin correspondente ao arquivo: /storieplus_plugin/videos.php

Compartilhe no Pinterest

Deixe um comentário