Skip to content
back2arie edited this page Jul 28, 2012 · 10 revisions

What is it good for?

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’s 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.

Base PHP API

It is pretty easy, you just need to include Kalkun_API.php file (located on scripts/cURL/) and send some parameters and done.

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 writeable
$config['username'] = "username"; // Username on Kalkun
$config['password'] = "password";
$config['phone_number'] = "123456"; // Your client/friend phone number
$config['message'] = "Test message from API"; // SMS content

$sms = new Kalkun_API($config);
$sms->run();

// Other job
// ...

As you can see, all you need is to change the config parameters based on your configuration.

base_url: your Kalkun URL, don’t forget the index.php/
session_file: a file that save your session a.k.a login credential, it must be writeable by web server user
username and password: your login credential for Kalkun, not your application
phone_number: destination phone number, you’ve to get it from your application (through database query)
message: the SMS content

That's it!

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.

REST API

This API can be used via simple HTTP GET method, for example:

http://kalkun-url/index.php/plugin/rest_api/send_sms?phoneNumber=123456&message=testing

Note: This is a plugin, you need to enable before use it.

XMLRPC

Sample XMLRPC client call using CodeIgniter XML-RPC Classes:

$this->load->library('xmlrpc');
$server_url = site_url('http://kalkun-url/index.php/plugin/xmlrpc/send_sms');		
		
$this->xmlrpc->server($server_url, 80);
$this->xmlrpc->method('send_sms');
$this->xmlrpc->set_debug(TRUE);
		
$request = array('1234', 'Testing XMLRPC');
$this->xmlrpc->request($request);

if (!$this->xmlrpc->send_request())
{
    echo $this->xmlrpc->display_error();
}
else
{
    print_r($this->xmlrpc->display_response());
}

Note: This is a plugin, you need to enable before use it.

JSONRPC

Sample HTTP POST method call:

http://kalkun-url/index.php/plugin/jsonrpc/send_sms

And the body:

{"method":"sms.send_sms", "params":{"phoneNumber":"1234","message":"Testing JSONRPC"}}

Note: This is a plugin, you need to enable before use it. Sample JSONRPC client call using Firefox RESTClient: http://azhari.harahap.us/2012/07/sample-jsonrpc-client-call-using-firefox-restclient/

Clone this wiki locally