Baca berita tanpa iklan. Gabung Kompas.com+

Membuat SMS POLLING Sederhana

Kompas.com - 22/04/2009, 10:41 WIB

13. Buat sebuah trigger pada database 'smsd' (trigger merupakan script SQL untuk memicu fungsi tertentu dalam dabase). Caranya:
• Buka "MySQL Command Line Client", Pilih : Start > All Programs > AppServ > 'MySQL Command Line Client'
• Isikan password MySQL
• Copy baris trigger berikut, kemudian paste di mysql command prompt sampai muncul tulisan 'Query OK, 0 rows affected'


**********************trigger*************************
delimiter $
create trigger
smsd.sms
AFTER
INSERT
on
smsd.inbox
for each row BEGIN
DECLARE smsx,smsz,smsmasuk varchar(200);
DECLARE format,pilihansms,no_pengirim varchar(200);
DECLARE error,x,jmlvote int;

set smsz=new.TextDecoded;
select ltrim(smsz) into smsx;
select rtrim(smsx) into smsmasuk;
set no_pengirim=new.SenderNumber;
select substring_index(smsmasuk,' ',1) into format;
select substring(smsmasuk,6) into pilihansms;
select count(pilihan) from polling.data_polling
where pilihan=pilihansms into x;
select vote from polling.data_polling
where pilihan=pilihansms into jmlvote;
set jmlvote=jmlvote+1;
set error=0;

if format='idol' and x>0 then
update polling.data_polling set vote=jmlvote where pilihan=pilihansms;
else
set error=1;
end if;

if error=1 then
insert into smsd.outbox values ('', '', '', NULL, no_pengirim, 'Default_No_Compression', NULL, -1, 'Maaf,format yang anda masukkan salah. Silahkan kirim ulang','', 'false',-1, '', '', '', '');
end if;

if error=0 then
insert into smsd.outbox values ('', '', '', NULL, no_pengirim, 'Default_No_Compression', NULL, -1, 'Terimakasih,pilihan anda telah kami tampung','', 'false',-1, '', '', '', '');
end if;

END;
$
**********************trigger*************************

14. Buka file smsdrc dengan Wordpad pada direktori Gammu (lihat nomor 4), dan edit bagian :
# ----------------- SETTINGS FOR --smsd MYSQL or --smsd PGSQL -------------------
user = root [ EDIT, isi dengan root ]
password = root [ EDIT, isi dengan password MySQL ]
pc = localhost
# pc can also contain port or socket path after colon (eg. localhost:/path/to/socket)
database = smsd [ EDIT, isi dengan nama database MySQL yaitu smsd ]
# when you send sms from some SMSC, you can have Delivery/Failed Delivery
# Reports from other SMSC number. You can set here number of this "buggy"
# SMSC used by you and Gammu will not check it's number during assigning
# reports to sent sms
#skipsmscnumber = +48602123456
# -------------------------------------------------------------------------------

Konfigurasi Device
15. Buka file gammurc dengan Wordpad pada direktori Gammu (lihat nomor 4). Kebetulan, PCplus menggunakan HP Nokia 3200 dan inframerah sebagai koneksinya. Edit bagian:
[gammu]
port = irda: [ EDIT, isi sesuai dengan port device yang digunakan ]
;model = 6110
connection = irdaphonet [ EDIT, isi sesuai dengan connection device yang digunakan ]
;synchronizetime = yes
;logfile = gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;usephonedb = yes

Catatan:
Untuk mengetahui 'connection' dari macam-macam tipe HP, kunjungi http://cihar.com/gammu/phonedb/.

16. Sekarang, kopikan file gammurc dan smsdrc ke direktori di mana file gammu.exe berada, yaitu pada : [Gammu-1.21.90-Windows-bin-].

Halaman:
Video rekomendasi
Video lainnya


Baca berita tanpa iklan. Gabung Kompas.com+
Baca berita tanpa iklan. Gabung Kompas.com+
Baca berita tanpa iklan. Gabung Kompas.com+
komentar di artikel lainnya
Baca berita tanpa iklan. Gabung Kompas.com+
Close Ads
Bagikan artikel ini melalui
Oke
Login untuk memaksimalkan pengalaman mengakses Kompas.com