Maret 01, 2016

Kode Blogger JSON Feed API

Kode Blogger JSON Feed API | Fredi Yana

Kode Blogger JSON Feed API - Blogger.com sejatinya mempunyai banyak sekali fungsi dalam menampilkan fitur-fitur tertentu. Kita mungkin terkadang perlu menggunakan widget dan sering kali memiliki kendala yaitu widget yang dibutuhkan tidak tersedia.

Nah dengan masalah seperti itulah Blogger selaku ibu telah menyediakan API untuk bisa mengatasi permasalahan tersebut, sehingga kita terbantu dalam membuat widget dengan cara membaca feed blog yang mempergunakan JSON dan juga JavaScript.

Ada yang belum paham dengan arti JSON itu sendiri? nah saya akan uraikan sedikit perihal tentang JSON tersebut.
Baca juga : Inilah 5 Fakta Google Menentukan SERP 2016
JSON atau sering kali dibaca Jason adalah singkatan dari JavaScript Object Notation (Notasi Objek JavaScript), yang artinya adalah Format ringkas pertukaran data komputer.

Berikut ini saya akan lampirkan beberapa Kode Blogger JSON Feed API :
Object  - (Description)
json.feed.id.$t (Show blog ID)
json.feed.updated.$t   (Last update of a blog)
json.feed.category[]  (Categories / label array of a blog)
json.feed.category[i].term   (Show the i-th category Blogger)
json.feed.title.$t   (Show blog name )
json.feed.subtitle.$t  (Show description of a blog )
json.feed.author[]  (Array of blog authors )
json.feed.author[i].name.$t  (Show the i-th blog author name )
json.feed.author[i].uri.$t  (Show the i-th profile author uri )
json.feed.openSearch$totalResults.$t  (Show total posts )
json.feed.entry[]  (Posts array of a blog)
json.feed.entry[i].id.$t  (Show the i-th post ID )
json.feed.entry[i].title.$t  (Show the i-th post title )
json.feed.entry[i].published.$t  (Show time published of the i-th post )
json.feed.entry[i].updated.$t  (Show when the i-th post is updated )
json.feed.entry[i].category[]  (Show array of post categories)
json.feed.entry[i].category[x].term  (Show the x-th category of the i-th post )
json.feed.entry[i].summary.$t  (Show post summary )
json.feed.entry[i].content.$t  (Show post content )
json.feed.entry[i].link[]  (Links array of a post
json.feed.entry[i].link[x].href  (Show the x-th link of the i-th post )
json.feed.entry[i].author[]  (Array of post authors)
json.feed.entry[i].author[x].name.$t  (Name of the x-th author on the i-th post)
json.feed.entry[i].author[x].uri.$t  (Show uri author profile)
json.feed.entry[i].author[x].gd$image.src  (Image uri of the x-th author profile on the i-th post)
json.feed.entry[i].media$thumbnail.url  (Show image on the i-th post)
json.feed.entry[i].thr$total.$t  (Show total threaded comments)
Berikut adalah contoh yang teramat sederhana dari kode yang saya lampirkan diatas tersebut :
Baca juga : Cara Memanjakan Pengunjung Agar Berlama-lama di Blog
Semisal saya hanya memerlukan 5 buah postingan terbaru yang berdasarkan label yang telah saya pilih, misalnya "Hiburan" dan saya hanya mengambil ringkasan pos dan juga judul.

<script type="text/javascript">
  function mycallback(json) {
  for (var i = 0; i < json.feed.entry.length; i++) {
  for (var j = 0; j < json.feed.entry[i].link.length; j++) {
  if (json.feed.entry[i].link[j].rel == 'alternate') {
  var postUrl = json.feed.entry[i].link[j].href;
  break;
  }
  }
  var postTitle = json.feed.entry[i].title.$t;
  var postSummary = json.feed.entry[i].summary.$t;
  var item = '<div class="wrapper"><h3><a href=' + postUrl + '>' + postTitle + '</h3></a><p>' + postSummary + '</p></div>';
  document.write(item);
  }
  }
</script>
<script src="http://nama.blogspot.com/feeds/posts/summary/-/Blogger?max-results=5&alt=json-in-script&callback=mycallback"></script>
 
Nah dengan penerapan yang sedemikian rupa maka akan didapatkan hasil yang kalian inginkan, kode JSON tersebut hanya akan bekerja apabila digabungkan dengan Javascript.



Kode Blogger JSON Feed API Rating: 4.5 Diposkan Oleh: Unknown