PHP

Extracting meta-data from SMPP TLV’s with Kannel

I have been relatively quiet the past few weeks with various operations going on, but seeing as I have a few minutes to spare I thought I would do a quick post explaining how to extract SMPP TLV’s using the new Kannel meta data features which are in the current CVS branch.

These are scheduled for the 1.5.0 stable release of Kannel, so for now you’ll need to do a CVS checkout of the main branch (as described in my previous posts).

I will be demonstrating how to set a test TLV and then extracting this data when a reply is received. Once you have setup your ‘smpp-tlv’ group, you simply need to specify an additional parameter in your smsbox request. This parameter is named ‘meta-data’. The format for this variable is ‘?<bind_type>?<dataset>’ currently the only supported bind type is ‘smpp’ but it was done this way to allow future support.

The dataset argument, is a URL encoded key/value pair string. So for these tests I have configured a smpp-tlv group called ‘my-custom-var’. In order to set this, I need to build a string like this for meta-data purposes.


?smpp?my-custom-var=This+is+a+cool+var

As you can see my-custom-var is set as a URL encoded variable, this will still need to be URL-encoded for submission in the meta-data parameter sent to smsbox.

So just to demonstrate, using PHP how you would build this string, you would use.

$bind_type = "smpp";
$my_custom_var = "This is a cool var";
$meta_data = "?".$bind_type."?my-custom-var=".urlencode($my_custom_var);
/* Now we need to urlencode this string */
$meta_data = urlencode($meta_data);
/* So URL would look like */
/* cgi-bin/sendsms?to=...&from=...&meta-data=$meta_data */

So now, when you set this to smsbox, it will be sent via the smpp bind as a TLV. Easy!

Now on the converse, if your smpp bind returns a TLV in a deliver_sm or other PDU, this will also passed to your URL (if you have configured it. Here below is a basic function for parsing the meta data out of this string.

/* This function will take the meta-data string and return an associative array */
function parse_metadata($var) {
        $pos = strpos($var, "?", 1) + 1;
        /* Simply stripping out bind type 'smpp', this can be modified if you need it :) */
        $var = substr($var, $pos);
        $data = parse_str($var, $out);
        return $out;
}

/* Example: */
$meta_data = parse_metadata($_GET['meta-data']);

echo "My custom var = ".$meta_data['my-custom-var'];

I hope this helps you with your SMPP TLV requirements. Good luck, don’t forget to email me if you need any assistance with Kannel/SMS, etc and I will do my best to help you as best I can.

Technorati Tags: , , ,

Kannel Web Configuration Tool v0.1 available

Hi everyone,

I have ‘released’ version 0.1 of the Kannel Web Configuration tool. I have created somewhat of a home page for it here for those who are interested.

It is available as ‘donation-ware’ with full source code. Admittedly it was done in a hurry so hopefully later releases will see some code enhancements.

I am more than happy to provide assistance wherever necessary on this project.

Enjoy!

Technorati Tags: , ,

Kannel Web Configuration Tool

Following on with my previous themes of making Kannel easier to use for everyone, I have spent some time creating a tool which I think makes it easier to configure Kannel. It is a web based configuration tool which edits Kannel configuration files directly (doesn’t rely on any third party databases etc). I wrote it in PHP to keep it simple.

Current features

  • Edit existing configuration files
  • Add new configuration groups (smsc’s, smsbox-route, sendsms-user, etc)
  • Based on the cfg.def from Kannel CVS 1.4.2 as of 2008/12/18

Features in progress

  • Live updates to Kannel without restart for SMPP/EMI and smsbox-route’s (patch of Kannel CVS required)

Coming soon

  • User authentication
  • Kannel analytics and monitoring
  • Audit trails of changes
  • Other live updates

I am looking for feedback on the tool and when I believe it is stable enough and usable enough I will release it. You can see the beta of this tool here: http://www.ddj.co.za/kannel-config/web/

Enjoy! Please comment on the blog or email me at kwc@ddj.co.za with feedback.

Technorati Tags: , , ,

Are we training enough Open Source competent people in SA?

PHPWorking on the “dark side” of development, ie, the Open Source side has many distinct advantages, but it is becoming more and more apparent that there is a major skills shortage in South Africa. In all the businesses I have worked with, one of the recurring problems is finding good open source versed developers and unix skilled system administrators.

The problem as I see it is many of the Universities, Technikons and private learning institutions are still focused on teaching ASP, Visual Basic, Windows Servers, and so on, and the market is becoming more and more saturated with these skills. Where as on the other side of the spectrum there are gaping holes for competent staff.

With that said, if you are one of the few highly skilled PHP/MySQL (don’t be modest now!) developers, please get in touch with me, with your CV and/or some code you have written, so I can point you to some companies who desperately need your skills and are willing to pay for them! Specifically in Cape Town, South Africa!

Technorati Tags: , , , ,

Clickatell 2.0

Clickatell has launched their new website, which is a considerable improvement on the previous edition. Congratulations to all the guys on the marketing team it is really an excellent result. I would urge you to visit the site at www.clickatell.com to find out exactly what is on the table.