Wednesday, June 12, 2013

Bikin Notif Pengunjung ala Facebook diBlog (versi Google Script)

Udah gak usah dijelasin lagi kali kayanya ya, noh tuh kan contonya (kalo masih) ada dipojok kiri bawah.

Dulu di Blog yang lama juga udah pernah dishare scriptnya kalo gak salah, tapi emang yang itu DataBase untuk penyimpanan data pengunjung-nya masih pake Feed dari Facebook Page, nah kalo yang sekarang udah dipindah pake ScriptDB-nya Google Script.

Sebenernya kalo dibilang beda juga gak jauh-jauh amat kayanya, antara nyimpen sama ngambil datanya juga tetep pake API, cuman emang kalo ScriptDB-nya Google Script gak butuh Access_token, tapi kalo soal privacy data sih tetep aja public open; semua orang bisa access read/write.

Ada beberapa yang masih jadi ganjelan dari Blog Notif yang sekarang ini:
  • Apakah ada/Berapa limit penyimpanan dari ScriptDB ini.
  • Masih suka kepentok masalah Limit Eksekusi Script, jadi kalo pengunjung blognya rame, butuh lebih dari satu ScriptDB.
  • Belum ketemu gimana caranya biar write access ke-ScriptDB hanya bisa dari satu subdomain saja.
Karena disini bukan forum copy-paste, jadi mending kita bahas ditelnya dulu okeh?
udah, okeh aja,, daripada gak dibagi :P

ScriptDb

ScriptDb is a JavaScript Object database for Google Apps Script.

Saving Data

function saveToDB(){
  var db=ScriptDb.getMyDb();
  var whatToSave={
    visitor:{
      id:"4",
      name:"Zuck",
      page_title:"AingCreations",
      page_uri:"http://aingcreations-reborn.blogspot.com/",
      action:"viewed",
      browser:"Firefox 10",
      time:"2013-05-20T17:11:45+0000"
    }
  };
  db.save(whatToSave);
}

Collecting Data

function collectDB(){
  var visitors=[];
  var count=0;
  var limiting=5;

  var db=ScriptDb.getMyDb();
  var whatToCollect={visitor:db.anyValue()};
  var searchOnDB=db.query(whatToCollect);
  while(searchOnDB.hasNext()){
    var fromDB=searchOnDB.next();
    visitors.push(fromDB.visitor);
    count++;
    if(count==limiting){break}
  }

  var Lol="\nFound: "+visitors.length+" Visitors\n"+JSON.stringify(visitors,null,"  ");
  Logger.log(Lol);
}

Modifying Data

function modifDB(){
  var db=ScriptDb.getMyDb();
  var whatToModify={visitor:{id:"4"}};
  var modifPart={
    partName:"time",
    partVal:"2013-06-10T00:00:00+0000"
  }
  var searchOnDB=db.query(whatToModify);
  while(searchOnDB.hasNext()){
    var whatToSave=searchOnDB.next();
    whatToSave.visitor[modifPart.partName]=modifPart.partVal;
    db.save(whatToSave);
  }
}

Deleting Data

function dellDB(){
  var db=ScriptDb.getMyDb();
  var whatToDell={visitor:{id:"4"}};
  var searchOnDB=db.query(whatToDell);
  while(searchOnDB.hasNext()){
    db.remove(searchOnDB.next());
  }
}

ContentService

When a script is published as a web app, the special callback functions doGet() and doPost() are invoked whenever a request is made to the script's URL. The ContentService can be used to return raw textual content. This allows you to write scripts that act as services, responding to GET and POST requests and serving data of various mime-types.

Codes at Google Script

Publishing as a Web App

Testing

Getting visitor facebook ID

The important thing about this Blog Notif is visitor facebook ID. We can get this ID by connecting our blog to facebook or better known as Facebook Connect.

I'm not writing yet about this, but you may still learn it from http://developers.facebook.com/ or you may analyze this blog source script if you want :)

By knowing our visitor facebook ID, then we can fetch more information about our visitor from facebook, such as their profile photo, locale language, gender etc.

Tester HTML File

To learn more about how the script flows, Download this BlogNotifTester.htm file, open/drag and drop into browser new tab, use browser console to monitor the script flow.

~ Have a good day :)

61 comments:

CFx Nymouz said...

pertamax :p :D

pelangi senja said...

nah gue banget ini yang gue maling gak ketemu2 ..takzz kang irland



paling cetar membahana badai halilintar dah

pelangi senja said...

This comment has been removed by the author.

Mella said...

itu maksuntya scripnya ditaruh di html attau mana kang

Aing Uwi said...

teu jalan wae ahh

Ahmad Ulil said...

kumaha scripnya mana

CFx Nymouz said...

kang kalo yang di JS blog aing yang di ubah apanya ?
yang ini kan ?
dbUrls:[
"https://script.google.com/macros/s/AKfycbyuvCQpx3JqKFttIiWpuYV_K8Ey_FIYdRPz0_pen5MO5ZDCUaI/exec",
"https://script.google.com/macros/s/AKfycbwjzwgEZlabUXwOHrvqVNpji9I8Vv-8DROrCH4F_X78rgSBmJ-P/exec",
"https://script.google.com/macros/s/AKfycbztxXzd_dPj5vldzuQbHb9VJCILAtAKAaK1FVupRuNzpo97o1U/exec",
"https://script.google.com/macros/s/AKfycby3Xnf-LYF-UbS_8N3tb5FMzc5lpuzYNI3wKDrg6C6kDeMlMZU/exec"
],
dbUrl:"https://script.google.com/macros/s/AKfycbyuvCQpx3JqKFttIiWpuYV_K8Ey_FIYdRPz0_pen5MO5ZDCUaI/exec"
terus ngambil https://script.google.com/macros/s/AKfycbyuvCQpx3JqKFttIiWpuYV_K8Ey_FIYdRPz0_pen5MO5ZDCUaI/exec
linknya itu biar bisa saving data gimana ?
bingung ??

Aing Uwi said...

kang ningan teu jalan wae T.T

Aing Uwi said...

dbUrl na tos di ganti.
tapi teu muncul wae

Irlan Teumakede said...

Biar lebih ngerti soal cara kerja script ini, Download file BlogNotifTester.htm ini, open/drag and drop into browser new tab, use browser console to monitor the script flow.

~ Have a good day :)

Edwin IncRediable said...

Jadi pgn nge-Blog lagi.. thanks 4share kang Irland.. :P

Aing Uwi said...

masih belum paham :-D

Aing Uwi said...

scriptnya beda sama yang punya akang di pojok jadi pantes kalau di simpen di JS aing-creations dbUrl nya. gabakan jalan (kata ane)
tappi kalau di simpen di postingan kayak di atas jalan :-D

Pusing

CFx Nymouz said...

gk ngerti banget..
DbURl udh di ubah, terus yang "https://script.google.com/macros/s/AKfycbwjzwgEZlabUXwOHrvqVNpji9I8Vv-8DROrCH4F_X78rgSBmJ-P/exec",
"https://script.google.com/macros/s/AKfycbztxXzd_dPj5vldzuQbHb9VJCILAtAKAaK1FVupRuNzpo97o1U/exec",
"https://script.google.com/macros/s/AKfycby3Xnf-LYF-UbS_8N3tb5FMzc5lpuzYNI3wKDrg6C6kDeMlMZU/exec"


^^^
itu buat apa ?? fungsinya buat apa ??
??????
Bingung

Aing Uwi said...

CFx buat serep apan di atas udah di jelasin kalau pengunjungnya rame harus lebih dari satu script (mungkin)

Aing Uwi said...

hehe.
terus kumaha atuh teu jalan wae :/

CFx Nymouz said...

ohh buat serep toohh,, kirain tapi kalo di klik kok beda hasilnya ??
:/ :/ :/
yang 1 {"count":0,"data":[]}
yang 1 {"count":1,"data":[{"id":"100005026206828","page_uri":"http://aingcreations-reborn.blogspot.com/2013/06/bikin-notif-pengunjung-ala-facebook_12.html","time":"2013-06-15T22:58:15+0700","action":"viewed","brwsr":"Chrome 27","page_title":"Bikin Notif Pengunjung ala Facebook diBlog (versi Google Script) | AingCreations"}]}
????

Aing Uwi said...

kan kata ane juga script yang di share di postingan ini beda sama yang di pake di pojok

CFx Nymouz said...

ohh Beda tohh :/

Aing Uwi said...

Iya.
coba aja copas postingan ini pake page source terus ganti dbUrl nya pasti jalan.
tapi kalau di simpen di JS aing-creations ga jalan

CFx Nymouz said...

tes ahh :)

Aing Uwi said...

http://wis4nto.blogspot.com/2013/06/blog-notification-terbaru.html

tuh w juga jalan

CFx Nymouz said...

invite kang ke blognya, saya ilham :) :)

Jack Febrie said...

coba aja download dulu file htm yg buat ngetes di atas tuh
terus ganti dbUrls nya pake punya sendiri
terus masukin manual visitornya lewat form yang di pojok kanan bawah
terus liat jalan gak

liat di source file tadi ada function aing.posIpeun
liat variablenya kan pada beda sama source code js aing emang disengaja kale :P
var j={simpan:"euy",id:aing.idUserYgLogin,brwsr:aing.userBrowser,page:aing.dataNotip.pgUrl,title:i,type:aing.posipeuntype}

Aing Uwi said...

Udah jalan kalau lewat htm

oke lah di coba kang febrie :-D

Aing Uwi said...

Au ah pusiing :-D
Gimana ilham notif ini udah jalan belum ?

Ali Hadi Rafsanjani said...

Teu ngarti kang

Amelia Keilanda said...

wkwkwkk... CuMuNGuuuuttt kaKa².. XD

Aing Uwi said...

share atuh kang :'(

҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄ҳ-c(^3 -ҳ҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄ said...

gimana nih kang ? :v
masih bingung aku :3

҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄ҳ-c(^3 -ҳ҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄҃҄҅҆҅҄҃҄҅҆҅҄҃҄ said...

thisUri:"https://script.google.com/macros/s/AKfycbxIp8fOrlFt9576_d3V1jTpVb9wkLUpKlAu8tpxWeEomVIO69L8/exec",
ini diganti? dengan yang di 'deploy' barusan? :/

CFx Nymouz said...

belum jalan juga kang :/ :/
hadehh pusing,, mungkin karna gk ada visitornya yaa

matahari kesunyian said...

di test jalan di pasng og gak jalan dapuqqq

Cakka Nugraha said...

Monday, June 24 2013
Title Bar "Connecting.."
Status Bar "Waiting for script.google.com.."

Apakah fitur ContentServise Google Script akan Deprecated seperti pasilitas upload google code?

nya,,, ceuk aing oge ulah di Share :P jadi weh di paehan :D

Aing Uwi said...

hahah karunya teuing

UwiCreations said...

kang baheula mah saencan log.in teh aya foto budak ngelel :P ayeunamah teu aya.
Terus log.in with facebook na teu jalan deuih didieu mah :/

Akram D'Elitz said...

ada videonya ngga ?

Dwi Siswanto (CaFc Versace) said...

kang Irland nya lagi ngorok, jgn di ganggu :v
Kang Irland tambah pro nih :3 #culam :v

Dark iMz™ said...

heem.. low ada video nya pasti lebih greget nih..
manual kyk gni kyk nya buntu.. mana yg mesti di edit..

Dwi Siswanto (CaFc Versace) said...

ngapain pake video ? ini kan udah dijelasin secara detil =))

Dwi Siswanto (CaFc Versace) said...

kalo yg didemo kan ngeLoad nya aing.bikinNotip

Dark iMz™ said...

low db aing, notif nya low di load di blog.. weh lancar kyk jalan tol notif nya.. nah pas di ganti pke db sendiri cm ganti url db nya dowang.. eh malah diem seribu bhasa neh notif.. :/

yach.. kembali ke asal aja dah.. pke page

matahari kesunyian said...

masih penasaran uey,,anu ini mah
masamasukinnya manual tapi kalau di pasng yang masuk cuma orang2 yang di test tadi doang haaha
otak atik trus ampe jeboll

nah kalau copas yang di postingan ini bisa jalan di selipin di postingan,,tp masa sih setiap pposting harus di kasihh notip masing2 kwkwkwkwkwkw

pelangi senja said...

}
a={count:visitors.length,data:visitors};
}else{
a={error:"https://script.google.com/macros/s/AKfycbyQIGjF6qu7w2n9DKlyLxylRMaaxS0ad341SKConY1GB96k424r/exec?simpan=euy&id=4&brwsr=Firefox 10&page=http://zona-devil.blogspot.com/&title=ZonaDevil&type=viewed"};
}

}else{
a={error:"https://script.google.com/macros/s/AKfycbyQIGjF6qu7w2n9DKlyLxylRMaaxS0ad341SKConY1GB96k424r/exec?ambil=euy"};
}

}else{
a={error:"https://script.google.com/macros/s/AKfycbyQIGjF6qu7w2n9DKlyLxylRMaaxS0ad341SKConY1GB96k424r/exec?simpan=euy&uyeh=wkwk"};
}


apa udah bener ini kang

kurnia fajrin said...

Nyimmaakk.. kwakwkwk
Salam kang irland.. :*
senggol kang anaz :* :v

Aing Uwi said...

Kang upami tos kieu kumaha ?

http://wis4nto.blogspot.com/

dark ims™ said...

wah.. etamah mantap kang uwi

dripd ane gatot trs.. ckckk

dark ims™ said...

masih penasaran nih!!

masak ane bisa nya cuman copy paste :D
acak" trs akh

Aing Uwi said...

Inget Kata kata ini aja deh

Hanya parameter Ambil dan Simpan yang dapat di terima :D

dark ims™ said...

kyk gni bukan kang..
}else{
a={error:"https://script.google.com/macros/s/AKfycbwq0XErmOCkhGL4dMruHAaWAwwjudKnl5Sq3HUco9vJOHVYECs/exec?simpan=euy&id=100002688678274&brwsr=Firefox 20&page=http://dark--ims.blogspot.com/&title=dark ims&type=viewed"};
}

}else{
a={error:"https://script.google.com/macros/s/AKfycbwq0XErmOCkhGL4dMruHAaWAwwjudKnl5Sq3HUco9vJOHVYECs/exec?simpan=euy&id=4"};
}

}else{
a={error:"https://script.google.com/macros/s/AKfycbwq0XErmOCkhGL4dMruHAaWAwwjudKnl5Sq3HUco9vJOHVYECs/exec?ambil=euy"};
}

tp low di jalankan Dotget nya malah kyk gni hasil nya
(TypeError: Tak dapat membaca properti "parameter" dari undefined.)

Aing Uwi said...

Kang irland maksimal limiting di DB nya berapa ?

Rony Pinem said...

Kok eror parameter nih??
pass udah running Doget
if(e.parameter){
eror

Ilmu Gaib said...

mantab master irland :D

Li Yan said...

TypeError: Tak dapat membaca properti "parameter" dari undefined. (baris 10, file "Kode")



eror : if(e.parameter){


gimana si binggung

Irland Southerland said...

Who can access to the app nya kali?
(gambarnya gak jelas lagi ngapain?)

A̳̿i̳̿n̳̿g̳̿ B̳̿u̳̿d̳̿a̳̿k̳̿ S̳̿u̳̿n̳̿d̳̿a̳̿ said...


Teu Jadi Jadi Dah Urang Nyiem DB Teh T^T

Lier... Aya Vidiona Teu?

m.wasiu Rizqi said...

Gan masi belom paham ,
cara masang Notif Pengunjung ala Facebook diBlog

Mochammad Yoga said...

teu ngarti ngarti urang ahk , lieur error wae pas di run teh

The Ipeenk Creations said...

Kang, Cara bikin notif nya gimana. ko notif nya masih ga jalan. apa app fb nya harus di setting ke publik dulu ya kang

mohon bantuan nya kang, ini blog sy http://irfan-newbie.blogspot.com


makasih kang

nguyenhuong said...

Thanks for sharing, nice post!

Máy đưa võng hay võng tự đưa là một món quà vô cùng ý nghĩa cho bé yêu của bạn, võng đưa em bé giúp cho các bé có giấc ngủ ngon hơn mà võng đưa tự động không tốn sức ru võng của bố mẹ. Võng tự động hay mua may dua vong chắc chắn, gọn gàng, dễ tháo xếp, dễ di chuyển và may dua vong dễ dàng bảo quản. Những lợi ích mà máy đưa võng mang lại là vô cùng thiết thực.

Chia sẻ 4 mẹo tăng cường trí nhớ cho dân văn phòng cực hiệu quả hay bí quyết trị sẹo thâm bằng rau má, chia sẻ kinh nghiệm bé ăn gì để thông minh hơn hay thực phẩm giúp trẻ thông minh hơn, mẹo hay giúp trẻ thích ăn rau hay cách giúp trẻ hạ sốt nhanh hiệu quả hay làm cách nào để trẻ hạ sốt nhanh các mẹ cần biết, bệnh viêm khớp không nên ăn gì, một số mẹo giúp giảm độ cận thị cho bạn, bí quyết chống nắng với cà chua cực hiệu quả hay những thực phẩm giúp tóc mọc nhanh hiệu quả, cách giúp bé ngủ ngon giấcthực phẩm giúp bé ngủ ngon mẹ nên biết, chia sẻ cách làm trắng da toàn thân bằng thực phẩm, những món ăn chữa bệnh mất ngủ giúp ngủ ngon, mách mẹ mẹo giúp bé không sốt khi mọc răng hay làm sao để trẻ không bị sốt khi mọc răng

Những thực phẩm giúp đẹp da tại http://nhungthucphamgiupda.blogspot.com/
Thực phẩm giúp bạn trẻ đẹp tại http://thucphamgiuptre.blogspot.com/
Thực phẩm làm tăng tại http://thucphamlamtang.blogspot.com/
Những thực phẩm giúp làm giảm tại http://thucphamlamgiam.blogspot.com/
Những thực phẩm tốt cho tại http://thucphamtotcho.blogspot.com/

Sophie Grace said...

I really like the pics of your article. All the outfits are nice but my favourite is the first one. The top and the harness look so good together. picbear