Ryan Jabat

Wednesday 30 January 2013

Membuat Cronjob Dengan Google Drive

Pastikan punya email Gmail kemudian Login dan masuk disini 

Kemudian klik BUAT 
Seperti GAMBAR  ini :

Lalu Pilih SPREADSHEET
Lihat GAMBAR :

Selanjutnya KLIK "Spreadsheet Tidak Berjudul" dan kasih judul, Saya Ambil Contoh disini saya kasih nama CronJob.
Lihat Gambar :

Perhatikan GAMBAR berikut :
Pada anak panah 1 ada "KODE SHEET"yg harus disimpan di notepad
Kemudian klik anak panah nomor 2 "EDITOR SCRIPT"

Setelah Klik editor script akan keluar tampilan berikut :

Klik anak panah 1 kemudian akan muncul anak panah 2 ganti nama misal saya ambil contoh KOMEN lalu perhatikan anak panah nomor 3 ganti dengan script berikut :
Copy Kode Berikut



function cronExecute() {

var url = "http://www.domaninMU.com/komen.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("KEY-SHEET");
// 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

}

Yang perlu diganti adalah yg berwarna merah dengan alamat botmu

Terakhir tinggal save anak panah 1, lalu seting waktunya anak panah 2, kemudian jalankan Cronjob anak panah 3 :

Related Posts by Categories

0 comments: