-
Notifications
You must be signed in to change notification settings - Fork 130
Let say that you have some application like Point Of Sale, SAP, ERP, or other application that contains information about your client or friends, and somehow you want to reach them via SMS. OK, you have install Kalkun and it runs well, but how you send SMS with contact from other application? add/import it to Kalkun phonebook? Hmmm, it's OK if you have only a few contact, but how about hundred or thousand contact? Your data will become redundant and hard to maintain.
Available methods:
It is pretty easy, you just need to include Kalkun_API.php
file (located on scripts/cURL/
) and set some parameters.
include_once("Kalkun_API.php");
// some logic here, eg: database query to get phone number, and looping it
// ...
$config['base_url'] = "http://localhost/kalkun/index.php/"; // Kalkun URL
$config['session_file'] = "/tmp/cookies.txt"; // session file, must be writable
$config['username'] = "username"; // Username on Kalkun
$config['password'] = "password";
$config['phone_number'] = "+123456"; // Recipient phone number
$config['message'] = "Test message from API"; // SMS content
$sms = new Kalkun_API($config);
$sms->run();
// Other job
// ...
To run it from command line:
php example.php
As you can see, all you need is to change the config parameters based on your configuration.
- base_url: Kalkun server URL, don't forget the index.php/
- session_file: a file that saves your session a.k.a login credentials, it must be writeable by web server user if you launch it through web server, or by the user running the command if you launch it from command line.
- username and password: your login credentials for Kalkun.
- phone_number: Recipient phone number, you've to get it from your application (through database query). Set it to international format.
- message: SMS content
Note: This only works on PHP script, of course you can use it (with some modification) with other language that support cURL or standard POST method.