Rabu, 30 Januari 2013

Cara membuat cronjob di google drive

Pertama anda sign in ke google drive :







kemudian klik buat trus pilih spreadsheet
isi judul terserah anda, kemudian klik alat, editor skrip











langkah selanjutnya isi kolom kode.gs dengan skrip dibawah ini :

function cronExecute() {
var url = "http://domain.com/bot.php";
var options = {
"method" : "get",
"headers" : {'User-Agent' : 'Mozilla Firefox 14.0',
'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
},
"payload" : "",
"contentType" : "application/xml; charset=utf-8"
};
var request_starttime = new Date();
// fetch the HTTP / HTTPS request and get the response
var response = UrlFetchApp.fetch(url,options);
var request_endtime = new Date();
// use any spreadsheet, use its key
// var ss = SpreadsheetApp.openById("ISI KEY");
// use this script's default spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
// get the worksheet
var sheet = ss.getSheets()[0];
// inserting values into the sheet
sheet.insertRowBefore(1);
var colValues = [[ request_starttime, request_endtime,
response.getResponseCode(), response.getHeaders().toSource(),
url, response.getContentText() ]];
sheet.getRange(1, 1, 1, 6).setValues(colValues);
// if something is not working, use the Logger object/function (uncomment it and modify it)
// Logger.log(ss.getSpreadsheetTimeZone());
// view the log details from VIEW -> LOGS
// You can also RUN the script and view its Execution log
// try this VIEW -> EXECUTION TRANSCRIPTS
// Make sure you MODIFY and then RUN the script and
// verify its working OK by looking at the spreadsheet contents
// try this RUN -> CRONEXECUTE
// check the spreadsheet contents
// After its working OK, you should setup a TRIGGER to execute it as and when you want (frequency)
// try this TRIGGERS -> ALL YOUR TRIGGERS
}





pastekan skrip tsb di kolom kode.gs
kemudian isi url yang mau di eksekusi dan anda diharuskan mengisi key pada laman sebelumnya
masih bingung?? ok dah aku kasih potonya :D

dan untuk key di laman sebelumnya ini dia picture nya



bila sudah klik simpan
trus tinggal set cronjobnya deh pilih
pemicu cron saat ini :
untuk set time bisa menggunakan setiap jam ataupu setiap menit






udah deh selesai ^_^
maaf blog nya belepotan,, newbie kaka :p






5 komentar:

  1. untuk membuat cronjob om, bilamana cronjob di hostingnya sendiri ga mau jalan.

    BalasHapus
  2. Wah artikelnya sangat bermanfaat nih sob, share terus yang seperti ini yah saya akan berkunjung lagi nanti, salam blogger semoga sukses.
    Jangan lupa mampir keblog saya http://rizkyseo.blogspot.com

    BalasHapus
  3. iya mampir langsung nih om

    BalasHapus