Kode JSON Feed API di Blogger

Discussion in 'Blogger' started by KangAndre, Feb 21, 2016.

  1. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    Blogger.com sebenarnya memiliki banyak fungsi untuk menampilkan fitur tertentu. Mungkin kadang-kadang kita perlu widget namun widget tidak tersedia. Blogger sudah menyediakan API untuk mengatasi hal ini, sehingga kita bisa membuat widget sendiri dengan membaca feed blog menggunakan JSON dan JavaScript.

    Kode JSON feed API Blogger:
    Code:
    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 ini adalah contoh sederhana dari kode di atas:

    Misalkan saya perlu 5 posting terbaru berdasarkan label tertentu misalkan "Blogger" dan hanya mengambil judul dan ringkasan pos.
    Code:
    <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>
    
    Dengan demikian fungsi kode Json akan bekerja jika digabungkan dengan Javascript.

    Mungkin ada yang ingin mempelajari blogger.com lebih mendalam, blogger json feed api ini bisa berguna. Silahkan puyeng :D

    Sumber: http://www.danpros.com/2013/08/blogger-json-feed-api
     
    lasealwin and varjoe like this.
  2. yungga19

    yungga19 Active Member

    Joined:
    Nov 28, 2015
    Messages:
    1,455
    Likes Received:
    85
    Trophy Points:
    48
    Wuih pembahasannya udah advanced ane ga paham
     
  3. Rimala Nursery

    Rimala Nursery Super Level

    Joined:
    May 29, 2014
    Messages:
    2,089
    Likes Received:
    254
    Trophy Points:
    83
    Btw ... Json itu apa ya kang ????
     
  4. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    JSON (dibaca Jason) JavaScript Object Notation (notasi objek JavaScript) format ringkas pertukaran data komputer.
     
  5. Pradytya Saputra

    Pradytya Saputra Member

    Joined:
    Feb 17, 2016
    Messages:
    127
    Likes Received:
    9
    Trophy Points:
    18
    Google+:
  6. Qoeple

    Qoeple Member

    Joined:
    Nov 21, 2015
    Messages:
    551
    Likes Received:
    90
    Trophy Points:
    28
    Google+:
    Json itu musuhnya Freddy, khan dulu pernah ada film nya "Freddy VS Json" :D
     
  7. Rimala Nursery

    Rimala Nursery Super Level

    Joined:
    May 29, 2014
    Messages:
    2,089
    Likes Received:
    254
    Trophy Points:
    83
    Masa ?????....


    Bodo !!! Hahahahhaha
     
  8. Minecraftndns

    Minecraftndns Active Member

    Joined:
    Dec 13, 2015
    Messages:
    922
    Likes Received:
    100
    Trophy Points:
    43
    wahwahwahhh balik lagi buat ngutak-ngatik isi dalem si istri lagi nih :D
     
  9. Qoeple

    Qoeple Member

    Joined:
    Nov 21, 2015
    Messages:
    551
    Likes Received:
    90
    Trophy Points:
    28
    Google+:
    Ada Ki Joko Bodo tuh tetangga Ane, ekekekkekeke
     
    Rimala Nursery likes this.
  10. dimensidata

    dimensidata Member

    Joined:
    May 22, 2015
    Messages:
    236
    Likes Received:
    33
    Trophy Points:
    28
    Google+:
    Wow, TOP BGT, jawaban yg snagat singat, padat dan jelas kang
     
  11. ranggadek

    ranggadek Member

    Joined:
    Feb 16, 2015
    Messages:
    373
    Likes Received:
    29
    Trophy Points:
    28
    masalah kode 100% saya tidak paham sedikitpun. pusing rasanya mempelajarinya
     
  12. Yuyutsu

    Yuyutsu Member

    Joined:
    Mar 22, 2015
    Messages:
    315
    Likes Received:
    35
    Trophy Points:
    28
    @KangAndre , ada keterangan 'Unexpected token' pada javascript saat saya coba di codepen[.]io.
     
  13. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    kemungkinan bisa terjadi saat menyalin kode dari dokumen lain (seperti PDF) ke dalam konsol karena karakter bisa berubah (mis tanda kutip standar dengan kutipan keriting)
     
  14. Yuyutsu

    Yuyutsu Member

    Joined:
    Mar 22, 2015
    Messages:
    315
    Likes Received:
    35
    Trophy Points:
    28
    Saya nyalin kode js-nya dari yg @KangAndre cantumin dan ga ngerubah apa pun terus muncul keterangan seperti itu. BTW, kode js yg @KangAndre cantumin jadi bisa inspirasi.
     
  15. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    Js memang sedikit peka, terkadang kelebihan spasi atau enter saja sudah salah. Juga berkaitan dengan program bahasa lain (html,php, dll) yang bisa bikin error jika "string" nggak tepat.
     
  16. vibicla

    vibicla Member

    Joined:
    Dec 23, 2015
    Messages:
    73
    Likes Received:
    3
    Trophy Points:
    8
  17. DwiKhasbullah

    DwiKhasbullah Well-Known Member

    Joined:
    Aug 7, 2014
    Messages:
    1,953
    Likes Received:
    138
    Trophy Points:
    63
  18. Si Raja

    Si Raja Member

    Joined:
    Nov 24, 2015
    Messages:
    851
    Likes Received:
    70
    Trophy Points:
    28
    Baru tahu nich.
    Ane bisa nulis aja Den.
     
  19. dadang

    dadang New Member

    Joined:
    Feb 23, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    kalo lihat script model gitu mah harus ngeja baca nya bukan lagi per kata tapi harus di awasin huruf per huruf sama tanda baca nya
     
  20. Imampras

    Imampras Member

    Joined:
    Jan 20, 2016
    Messages:
    89
    Likes Received:
    5
    Trophy Points:
    8
    Bahasannya terlalau tinggi belum bisa dimengerti, puyeng :confused: masih perlu banyak belajar mendalam lagi
     
Loading...
Similar Threads - Kode JSON Feed
  1. Rswd
    Replies:
    0
    Views:
    1,267

Share This Page