SELAMAT DATANG

SELAMAT DATANG - SEMOGA BLOG INI BERMANFAAT

Rabu, 26 Agustus 2015

Cara Membuat SMS Gateway untuk Pemula Dengan Gammu dan PHP


Sebelumnya saya sudah membuat aplikasi SMS Gateway dengan gammu yaitu Aplikasi Reservasi Klinik Rumah Sakit. Sekarang saya akan menjelaskan bagaimana cara membuat SMS Gateway sendiri dengan Gammu dan PHP.
Membuat SMS Gateway untuk Pemula Dengan Gammu dan PHP 
 
Yang perlu dipersiapkan adalah :
1. Local WebServer seperti XAMPP , AppServ , WAMP
1. Aplikasi Gammu, saya memakai OS Windows karena kebanyakan orang pakai Sistem Operasi ini
2. Modem Plug n Play (Modem GSM,Modem CDMA)
3. Sebuah kartu GSM/CDMA yang sudah terisi pulsa ( kalau tidak ada pulsa mau ngapain? :D )
4. Sedikit mengetahui pemrograman PHP
Hanya itu? ya benar, hanya itu saja yang diperlukan.

Berikut modul step by step nya :
pertama ini, saya akan menjelaskan bagaimana cara installasi Local WebServer . Saya memakai XAMPP untuk Local WebServer nya. Apa fungsi Aplikasi Tersebut ? Local WebServer berfungsi untuk menjalankan perintah PHP dan MySQL (Database)



Download Aplikasi XAMPP

(versi terbaru saat artikel ini dibuat adalah 1.81 )
Setelah di download, jalankan XAMPP Setup, Jika Parental Control masih aktif , anda bisa menonaktifkan fitur tersebut atau klik kanan Setup tersebut Run As Administrator

Klik Next

Pilih komponen yang akan diinstall, rekomendasikan pilihan saya ini, karena kita akan menginstall komponen yang seperlunya saja

Install komponen Apache,MySQL,PHP,Perl dan PhpMyAdmin dan klik Next

Pilih folder installasi , rekomendasikan juga di C:\xampp

Uncheck Learn More about BitNami for Xampp
Klik Next dan Next.

Setelah anda menginstall xampp , maka untuk password defaul MySQL adalah :
username : root
password : (kosong)

Tes Local WebServer bekerja apa tidak 
Buka browser (firefox/opera/chrome) lalu ketikkan http://localhost
Jika Local WebServer bekerja maka ditampilkan halaman ini




Install Service Xampp agar berjalan pada startup Windows. Fungsinya agar tidak susah payah menjalankan xampp.

Klik Start Windows (bawah kiri Windows ) cari dan klik submenu Xampp 1.8.1 pilih XAMPP Control Panel



1. Klik Stop Action Apache dan MySQL
2. Check Module Service Apache dan MySQL
3. Klik Start Actions Apache dan MySQL kembali
Keterangan : Jika anda memiliki installasi Local WebServer lainnya yang terinstall pada Port 80, maka disable terlebih dahulu atau uninstall sekalian 3:)

Selesai, Xampp akan berjalan otomatis saat Windows Start

Download gammu untuk Windows 32 atau 64 Bit  ( Jika Windows anda versi 64 Bit maka ada folder pada C:\program files (x86) ).


Saya mendownload versi minimal , saat artikel ini dibuat versi gammu 1.33.0

Buat sebuah folder smsku pada c:\xamp\htdocs

Buka file gammu yang didowload tadi dengan winrar atau tools compression lainnya. Klik folder bin pada file gammu zip tersebut, lalu copy gammu yang di dowload tadi ke dalam folder smsku dengan menseleksi semua filenya dan drag ke folder smsku


Ok guys, kita udah sampai setengah jalan untuk membuat aplikasi sms gateway dengan gammu dan php

Setelah 2 artikel sebelumnya, sekarang saya akan memberikan artikel konfigurasi gammu.
Ayo,modem USB dan kartu perdana GSM/CDMA tadi mana? apa sudah registrasi kartunya dan diisi pulsa? Jika sudah colokin Modem USB ke USB komputer, dan install paket drivernya
Di sini saya memakai Modem USB Advance

Cari port modem usb
Jika modem usb sudah terinstall dengan benar, maka buka Control Panel -> Device Manager





Buka kategori modem, nah di sana ada berbagai macam driver modem. Jika anda tidak tahu modem usb mana yang tertera pada kategori modem tersebut, copot lagi modem dan pasang lagi. Nah device manager otomatis refresh list driver modem nya. Tahu maksud saya kan? :D
Modem USB saya di sini Global Wireless USB Modem, klik kanan dan klik properties. Klik tab modem

Modem saya menggunakan Port COM9 dan Maximum Port Speed 921600. Jadi untuk konfigurasi jenis koneksi/speed maximum modem begini :


at = maximum speed 921600

at115200 = maximum speed 115200



Membuat file Konfigurasi
Sekarang masuk ke folder c:\xampp\htdocs\smsku
Buka notepad dan tulis :



[gammu]

# isikan port modem USB di bawah ini

port = COM9:

# isikan jenis connection di bawah ini

connection = at




simpan dengan nama gammurc (tidak pakai extension)

Buat database untuk gammu
Buka browser dan ketik (1)http://localhost/phpmyadmin
Klik (2)Database, Buat sebuah database (3) smskudb dan klik (4)Create


Buka kembali file gammu yang di download tadi, buka folder share -> doc -> gammu -> examples -> sql




Lalu import script mysql.sql dengan membuka http://localhost/phpmyadmin dan klik database smskudb, klik import . Klik browse, masuk folder smsku dan pilih mysql.sql dan klik Done



Buat konfigurasi database gammu
Buka notepad dan ketik :

[gammu]

# isikan port modem USB di bawah ini

port = COM9:

# isikan jenis connection di bawah ini

connection = at



[smsd]

service = mysql

logfile = smsdlog

debuglevel = 0

# Inisial modem

phoneid = Server1

commtimeout = 10

sendtimeout = 10

PIN = 1234

pc = localhost



# isikan user untuk akses ke MySQL (xampp default root)

user = root

# isikan password user untuk akses ke MySQL (xampp defaul null )

password = 

# isikan nama database untuk Gammu

database = smskudb



Lalu simpan dengan nama smsdrc

Tes koneksi modem
Buka command prompt/cmd ketikkan seperti gambar
Jika terbaca maka ada info detail modemnya, berarti konfigurasi nya sukses :)

Install Services Gammu agar jalan otomatis saat Windows Startup
Buka command prompt/cmd dan ketikkan

Konfigurasi gammu selesai :)

Menulis kode kirim sms dengan php
Buka folder c:\xampp\htdocs\smsku. Buat sebuah file kirimsms.php lalu tulis kode berikut :





<form method="post">

<label>No HP Format +62xxxxxxx </label>

<input type="text" name="nohp">

<label>Pesan</label>

<input type="text" name="pesan">

<input type="submit" name="button" value="Kirim">

</form>

<?php

if(isset($_POST['button']))

{

    mysql_connect("localhost","root","");

    mysql_select_db("smskudb"); 

    $query=mysql_query("INSERT INTO outbox (DestinationNumber,

    TextDecoded) VALUES ('".$_POST['nohp']."', '".$_POST['pesan']."')");

    if($query)

    {

        echo "<script>alert('Sukses kirim sms')</script>";

    }

}

?>
Keterangan :
Membuat form kirim pesan

<form method="post">

<label>No HP Format +62xxxxxxx </label>

<input type="text" name="nohp">

<label>Pesan</label>

<input type="text" name="pesan">

<input type="submit" name="button" value="Kirim">

</form> 
Jika tombol Kirim diklik

if(isset($_POST['button']))

{
Buat koneksi database, masih ingat bukan tutorial installasi Local WebServer ? mysql_connect fungsi php untuk mengkoneksikan sebuah server database mysql_connect(nama server,user database,password database), mysql_select_db fungsi php untuk memanggil database

mysql_connect("localhost","root",""); 

mysql_select_db("smskudb"); 
Query SQL atau bisa dikatakan perintah untuk MySQL Database. Lihat kembali http://localhost/phpmyadmin lalu pilih database smskudb, maka ada tabel outbox, nah tabel outbox tersebut diperintah untuk diiskan

$query=mysql_query("INSERT INTO outbox (DestinationNumber,

    TextDecoded) VALUES ('".$_POST['nohp']."', '".$_POST['pesan']."')");
 Jika query sql telah dijalankan, maka keluarkan output peringatan, kita sedikit menggunakan kode javascript :)

if($query)

    {

        echo "<script>alert('Sukses kirim sms')</script>";

    }
Nah mudah bukan?

tahap finalnya, setelah bisa mengirimkan sms. Sekarang kita akan membuat auto reply sms nya. Contoh Format REG#Nama#Tanggal#Jenis Kelamin#Alamat


Membuat kode auto reply sms

Masuk ke folder c:\xampp\htdocs\smsku dan buat sebuah file autoreply.php , ketikkan kode sebagai berikut:


<?php



mysql_connect("localhost","root","");



mysql_select_db("smskudb");



$query = "SELECT * FROM inbox WHERE Processed = 'false'";

$hasil = mysql_query($query);

while($data= mysql_fetch_array($hasil)){

    $id = $data['ID'];

    $noPengirim = $data['SenderNumber'];

    $msg = strtoupper($data['TextDecoded']);

    $pecah = explode("#",$msg);

    $d_tgl=$pecah[1];

    $d_nama=$pecah[2];

    $d_jk=$pecah[3];

    $d_alamat=$pecah[4];

    if($pecah[0]=="REG")

    {

        if($pecah[1] !="" and $pecah[2] !="" and $pecah[3] !="")

        {

            $today = date("Ymd");

            $tgl=date("d M Y");

            $newDate = date("Y-m-d", strtotime($d_tgl));



            $isinyo="Nomor ".$noPengirim." Nama ".$d_nama." JenisKel ".$d_jk." Alamat ".$d_alamat;

            $query=mysql_query("INSERT INTO outbox (DestinationNumber,

            TextDecoded) VALUES ('".$noPengirim."', '".$isinyo."')");      



        }else{

            $query=mysql_query("INSERT INTO outbox (DestinationNumber,

            TextDecoded, CreatorID) VALUES ('".$noPengirim."', 'Gagal Registrasi. Format : REG#Tanggal#Nama#PRIA/WANITA#Alamat')");

        }

    }else{

            $query=mysql_query("INSERT INTO outbox (DestinationNumber,

            TextDecoded) VALUES ('".$noPengirim."', 'Gagal Registrasi. Format : REG#Tanggal#Nama#PRIA/WANITA#Alamat')");

    }

    $query3 = "UPDATE inbox SET Processed = 'true' WHERE ID = '$id'";

        mysql_query($query3);

}

?> 
Keterangan :
Query Inbox , melakukan pencarian data inbox yang masuk dalam modem USB dan tabel inbox

$query = "SELECT * FROM inbox WHERE Processed = 'false'";

$hasil = mysql_query($query);
Looping data inbox

while($data= mysql_fetch_array($hasil)){

Membuat variabel untuk record data inbox

$id = $data['ID'];

$noPengirim = $data['SenderNumber'];

$msg = strtoupper($data['TextDecoded']);

Membagi format berdasarkan karaktek #

$pecah = explode("#",$msg);

$d_tgl=$pecah[1];

$d_nama=$pecah[2];

$d_jk=$pecah[3];

$d_alamat=$pecah[4];
Jadi $d_nama adalah isi dari format sms NAMA yang dikirimkan

Cek format SMS pertama sekali adalah REG dan Cek semua format SMS

 if($pecah[0]=="REG")

    {

        if($pecah[1] !="" and $pecah[2] !="" and $pecah[3] !="")

        {

Konversi tanggal php ke mysql

$today = date("Ymd");

$tgl=date("d M Y");

$newDate = date("Y-m-d", strtotime($d_tgl));

Setelah terkirim, maka status inbox tersebut sudah terkirim "true"

$query3 = "UPDATE inbox SET Processed = 'true' WHERE ID = '$id'";

        mysql_query($query3);


Ops, ini belum selesai. SMS Gateway tidak akan respon jika tidak ada eksekusi terlebih dahulu. Lalu bagaimana caranya ?
Buat sebuah bat script, buka notepad dan ketikkan :

C:\xampp\php\php -f C:\xampp\htdocs\smsku\autoreply.php 
Simpan dengan nama daemon.bat (terserah mau apa namanya)
Jadi,jika kita klik daemon.bat, maka semua sms pada tabel inbox yang statusnya false akan ter-kirim dengan sendirinya. Tapi apakah harus jalankan daemon.bat setiap kali?
Nah, ini yang jadi pertanyaan. Banyak orang memakai trigger mysql ataupun dengan memakai konfigurasi runonreceive pada gammu. Namun ada kendalanya
Dengan Trigger :
Format SMS tidak bisa dilakukan sesuka hati
Dengan runonreceive :
Terkadang saya mencoba malah tidak jalan

Solusi saya ya bikin aplikasi untuk menjalankan daemon.bat tersebut dengan Visual Basic hahaha..
Caranya mudah kok,tapi saya tidak menjelaskan dengan detail.
Buat sebuah project Visual Basic dan Masukkan Timer dengan Interval 1000 lalu masukkan script pada Timer :

Private Sub Timer1_Timer()
Shell daemon.bat, vbHide
End Sub

Lalu compile dan buat sebuah start up dengan menitipkan shortcut pada folder :
C:\Users\NAMAUSER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup



34 komentar:

  1. boleh juga ini tipsnya gan, makasih yaa...
    solder uap

    BalasHapus
  2. Nice Content! Want to install Hardware in HP Envy 5055? here the few tips to follow Before you perform the HP Envy 5055 wireless setup, you must complete the hardware setup first. go to 123hp.com setup To get more information.In the first place, navigate to the ‘Wireless Settings’ on your printer control panel and select the ‘Wireless Setup Wizard’ option. Consequently, your printer will scan for available networks Select your wireless network from the list. And follow the instruction

    BalasHapus
  3. It is very easy to set up any HP printer. Download and install the HP printer software form 123.hp.com/setup. Make sure your internet connectivity is good to download a bigger software file. If you have internet issues, you can use the installation CD to install the printer software on your computer system. Once you initialize the installation process, follow the onscreen prompts vigilantly. The prompts will help you to get through the software setup. The printer will prompt you to choose the network connectivity type. Prefer the one which you have. You can reach out to us on our toll-free number +1-844-876-5110 if you have any issues regarding the HP printer setup.

    BalasHapus
  4. I am a technical writer based at Tampa, USA and I have been writing blogs on many technical products that have impressed me so far. When it comes to streaming, I have explored a lot of devices. But I have never come across a product like Roku. It is fabulous and more dynamic in design. The shape resembles a Pendrive yet it could bring you loads of Entertainment. The features of the Roku player are pretty decent and especially the enhanced voice search is what impressed me the most. The search provides me almost every movie that I like
    My blogs:
    Roku.com/link
    Roku.com/link create account
    Roku.com/link activate account
    Roku.com/link account
    Roku.com/link activate
    Roku.com/link activation
    Roku.com/link enter code
    Roku.com/link setup
    Roku.com/link code
    activate Roku.com/link
    www.Roku.com/link
    Roku com link
    Roku com link create account
    Roku com link activate account
    Roku com link code
    Roku com link enter code
    Roku com link activate code
    Roku com link account
    Roku com link activate
    Roku com link activation
    Roku com link setup
    activate Roku com link
    activate Roku com link code

    BalasHapus
  5. As we all know, Roku ( Roku.com/link ) is a popular online live streaming platform ( go roku.com/hdcp ) used by millions of consumers across the globe. The end user must follow these simple steps to activate the Roku device ( go.roku.com hdcp ) successfull . like ( hdcp roku ) | (hdcp error roku) | (Roku.com/link code ) | (roku.com/link activation code ). The activation process for different Roku models is the same. Activation is free of cost and users need not incur any cost. The user inserts power cable and switches on to charge up the device.

    BalasHapus
  6. Are you new to Roku device? Facing difficulty while connecting Roku to your smart TV? We are here to help you. Here we provided the instructions for Roku setup. Follow the process to make your process easy.
    Initially make all the connections properly. Connect your Roku to the wireless network. Then set all the initial setup to the TV. Enter the language that you prefer, connect your Roku to the wireless network by entering the password. Additionally, you need to create the Roku account to enjoy all the streaming on the Roku, for entering the activation code while creating the account visit Roku com link account.
    For more and detailed information on the Roku device, you can visit the website.

    BalasHapus
  7. You will never feel bored watching the aetv channel shows such as Duck Dynasty, Storage Wars, Intervention and much more. If you have the requirements, channel activation can't be a tough job. Let us explain the aetv.com/activate steps here. Link your gadget to the account and visit the channel store category, Movies and TV. Add the channel and tap on the channel icon. Execute the onscreen prompts to collect the activation code. The last and final step is to visit the page,  aetv.com/activate. Select the device. Log in with the TV provider, if required and provide the activation code. If you need any guidance to activate this channel, dial the toll-free number +1-844-360-7450

    BalasHapus
  8. If your LCD/LED TV won't turn on, or makes repeated clicking sounds and display not screen, there is a very good chance that you can save time doing this best tv repair centre Mumbai. Samsung TV Service Center in Mumbai is best LED LCD TV service center in Mumbai. we provide Samsung TV repair service with affordable cost.

    BalasHapus
  9. iot training in chennai - IoT Training in Chennai - IOT is basically a technology connecting things with Internet known as Internet of things. The Best example for this is smart phones. Start learning IOT from the Best IOT Training Institute in Chennai.

    Devops training Institute in Chennai -DevOps has a technology domain has a better life. Most of the industries are using DevOps technology. DevOps has a different phase which has its own tool and easy to work. start to learn DevOps at the Best DevOps Training Institute in Chennai.

    blue prism training in Chennai - Blue prism is an trending technology which has enormous scope and value. Blue Prism is basically a Robotic process automation tool.

    uipath training in Chennai -path is an one of the tool used in Robotic process by the Uipath company. It's a demanded software or technology among the Rpi tools. find and enroll at the Best Ui path Training in Chennai.

    microsoft azure training in chennai - Microsoft azure is also a cloud computing technology which has better and wonderful scope in the future. Join the Best Microsoft azure training Institute in Chennai now.

    Chennai IT Training Center

    BalasHapus
  10. It would be pretty difficult to set up their HP Printer in a suitable way. The unprotected printer users may vary for generative instruction for the printer tool. That’s why; our technical engineers have fixed to advance a website i.e., hp officejet 100 mobile printer to give more information concerning HP Printer setup. So, if some users give access to this link, they will get to study how helpfully printers should be set up. Once the printer has effectively been set up also in a direct format, the users can flexibly print anything from their HP Printer system.

    BalasHapus
  11. I want multiple printers for scanning and copying help. I have chosen to pick an HP printer. I am a new user of HP products, so I don’t know anything about its features and tasks. I need to start a multiple HP printer with the help of 123.hp.com/setup.I am using my knowledge to open it in the internet browser and type my model number. After this command, I am finishing the next technical procedure. At the center of the process, I am experiencing issues. So I am sharing this issue with you too, guys. Could anyone refer to the right way to set up an HP printer using hp envy 4502 setup

    BalasHapus
  12. It would be pretty difficult to set up their HP Printer in a suitable way. The unprotected printer users may vary for generative instruction for the printer tool. That’s why; our technical engineers have fixed to advance a website i.e., 123 hp officejetpro6230 to give more information concerning HP Printer setup. So, if some users give access to this link, they will get to study how helpfully printers should be set up. Once the printer has effectively been set up also in a direct format, the users can flexibly print anything from their HP Printer system.

    BalasHapus
  13. In the event that you are a client of HP printer and searching for a source that can give you definitive advances and documents for the setup of HP printer, mind me, you should visit windows image acquisition driver This is one step goal to find all the documents and driver applications related to all the HP printer models. Along with this, we have indicated here a good and easy process for hp printer setup. So for what reason would you say you are stopping? Hit the connection and appreciate top-tier printing results.

    BalasHapus
  14. I want multiple printers for scanning and copying help. I have chosen to pick an HP printer. I am a new user of HP products, so I don’t know anything about its features and tasks. I need to start a multiple HP printer with the help of hp scanner driver download.I am using my knowledge to open it in the internet browser and type my model number. After this command, I am finishing the next technical procedure. At the center of the process, I am experiencing issues. So I am sharing this issue with you too, guys. Could anyone refer to the right way to set up an HP printer using hp scanner driver download

    BalasHapus
  15. The direct answer is certainly you can set up on your own. If you have just bought a new HP Printer and have no idea how to set it up. then you are at the right site 123.hp.com/setup.will assist you to set up your printer by providing step-by-step instruction which will make it appear as though a cake stroll to you. Just by going through the points, you will be able to set up your printer and get the printing started. further problems, feel comfortable to get in touch with us by calling on our 24x7 helpline customer support and the technician will solve your query.

    BalasHapus
  16. Do you have an HP printer? It needs some software to improve the performance of the HP printer, like driver software, Webscan, scanner software, scan doctor. These all software are performing differently by respective works like scanning your hp printer performance, identifying the printer errors, checking ink cartridge level and also paper struck problems. So you need this type of software contact our website hp smart app (smart app, scan doctor, Webscan)

    BalasHapus
  17. In the event that you are a client of HP Envy Setup and searching for a source that can give you definitive advances and documents for the setup of HP Envy Setup, mind me, you should visit 123.hp.com/envy 5055. This is one step goal to find all the documents and driver applications related to all the HP Envy Setup models. Along with this, we have indicated here a good and easy process for hp printer setup. So for what reason would you say you are stopping? Hit the connection and appreciate top-tier printing results.

    BalasHapus
  18. Do you met your hp printer offline because of any interrupted in wireless connection, disconnection printer receiver problem, printer not connected with the devices, so it may be very difficult or easy to fix based on their type of problem so feel free, we are here for fix your hp printer offline problem by well-experienced printer technician by through online session of our website hp officejet 100 mobile printer.

    BalasHapus
  19. Do you have an HP printer? It needs some software to improve the performance of the hp printer, like driver software, Bluetooth driver, smart app, scanner software, scan doctor. These all software are performing differently by respective works like scanning your hp printer performance, identifying the printer errors, checking ink cartridge level and also paper struck problems. So you need this type of software contact our website hp scanner driver download (smart app, scan doctor, driver software, scanner software)

    BalasHapus
  20. In the event that you are a client of HP deskjet printer and searching for a source that can give you definitive advances and documents for the setup of HP deskjet printer, mind me, you should visit 123.hp.com. This is one step goal to find all the documents and driver applications related to all the HP printer models. Along with this, we have indicated here a good and easy process for hp deskjet printer setup. So for what reason would you say you are stopping? Hit the connection and appreciate top-tier printing results.

    BalasHapus
  21. Do you have an HP printer? It needs some software to improve the performance of the HP printer, like driver software, Webscan, scanner software, scan doctor. These all software are performing differently by respective works like scanning your hp printer performance, identifying the printer errors, checking ink cartridge level and also paper struck problems. So you need this type of software contact our website HP DeskJet 2540 Scan

    BalasHapus
  22. I want a wireless HP deskjet scanner for wireless printing favor. Wireless printing technology permits the users to print the files wirelessly simply. It makes users feel free and the best way to get the printout of any file easily. In the initial stage, I have opened 123. hp/setup in my special chrome browser and have typed the model number of my wireless printer in the shown box of 123.hp.com. After this process, I execute the show to finish the setup process. I am confronting issues in this process, so I need to take the unique help from an online technician. So anyone can assist me to set up an HP wireless deskjet scanner via HP DeskJet 2540 wireless setup.

    BalasHapus