Blogger: Show All Subjects

PHOTO EMBED

Thu May 30 2024 22:39:48 GMT+0000 (Coordinated Universal Time)

Saved by @rmdnhsn #blogger

<!DOCTYPE html>
<html>
<head>
  <title>أسماء المواضيع</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }
    .post-list {
      list-style-type: none;
      padding: 0;
    }
    .post-list li {
      margin: 5px 0;
    }
  </style>
</head>
<body>
  <h1>أسماء المواضيع</h1>
  <ul class="post-list" id="post-list"></ul>

  <script>
    function fetchPosts() {
      const blogId = 'blogId'; // استبدل YOUR_BLOG_ID بمعرف مدونتك
      const apiKey = 'apiKey'; // استبدل YOUR_API_KEY بمفتاح API الخاص بك

      const url = `https://www.googleapis.com/blogger/v3/blogs/${blogId}/posts?key=${apiKey}`;

      fetch(url)
        .then(response => response.json())
        .then(data => {
          const posts = data.items;
          const postList = document.getElementById('post-list');
          
          posts.forEach(post => {
            const listItem = document.createElement('li');
            const link = document.createElement('a');
            link.href = post.url;
            link.textContent = post.title;
            listItem.appendChild(link);
            postList.appendChild(listItem);
          });
        })
        .catch(error => console.error('Error fetching posts:', error));
    }

    document.addEventListener('DOMContentLoaded', fetchPosts);
  </script>
</body>
</html>
content_copyCOPY

استبدال معرف المدونة ومفتاح API: استبدل YOUR_BLOG_ID بمعرف مدونتك. يمكنك العثور على معرف المدونة في عنوان URL للوحة التحكم، سيكون شيئًا مثل 1234567890123456789. استبدل YOUR_API_KEY بمفتاح API الخاص بك. يمكنك الحصول على مفتاح API من خلال Google Developer Console.