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-nyamasih pake Feed dari Facebook Page, nah kalo yang sekarang udah dipindah pake ScriptDB-nya Google Script. |
Sebenernya kalo dibilang
bedajuga 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
ganjelandari 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
- No Parameters
- https://script.google.com/macros/s/ ... /exec
- Wrong Parameters
- https://script.google.com/macros/s/ ... /exec?naonnya=euy
- Missed Parameters
- https://script.google.com/macros/s/ ... /exec?simpan=euy&id=4
- Collecting Data
- https://script.google.com/macros/s/ ... /exec?ambil=euy
Getting visitor facebook ID
The important thing about this
I'm not writing
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.
Blog Notifis visitor facebook ID. We can get this ID by connecting our blog to facebook or better known as Facebook Connect.
I'm not writing
yetabout 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 :)