. <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Müzik Önerisi</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div>
<button onclick="getMusicRecommendation()">Müzik Önerisi Al</button>
<p id="musicRecommendation"></p>
</div>
<script>
const apiKey = 'YOUR_YOUTUBE_API_KEY'; // Bu yere kendi YouTube API anahtarınızı ekleyin
function getMusicRecommendation() {
// YouTube API tarafından sağlanan bir örnek sorgu
const apiEndpoint = 'https://www.googleapis.com/youtube/v3/search';
const query = 'music';
const maxResults = 1;
const apiUrl = `${apiEndpoint}?part=snippet&key=${apiKey}&type=video&q=${query}&maxResults=${maxResults}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
const videoId = data.items[0].id.videoId;
const videoTitle = data.items[0].snippet.title;
const videoUrl = `https://www.youtube.com/watch?v=${videoId}`;
document.getElementById('musicRecommendation').innerHTML = `
<strong>Önerilen Müzik:</strong><br>
<a href="${videoUrl}" target="_blank">${videoTitle}</a>
`;
})
.catch(error => console.error('Erro
r:', error));
}
</script>
</body>
</html> YouTube API Kullanarak Müzik Öneri
0
●94
- 12-11-2023, 18:01:37