<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Donald Jackson &#187; TLV</title>
	<atom:link href="http://www.ddj.co.za/archives/tag/tlv/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ddj.co.za</link>
	<description>Kannel, mobile and web development</description>
	<lastBuildDate>Mon, 05 Jul 2010 09:18:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Extracting meta-data from SMPP TLV’s with Kannel</title>
		<link>http://www.ddj.co.za/archives/71/extracting-meta-data-from-smpp-tlvs-with-kannel</link>
		<comments>http://www.ddj.co.za/archives/71/extracting-meta-data-from-smpp-tlvs-with-kannel#comments</comments>
		<pubDate>Sun, 15 Mar 2009 13:18:13 +0000</pubDate>
		<dc:creator>Donald Jackson</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Kannel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[SMPP]]></category>
		<category><![CDATA[TLV]]></category>

		<guid isPermaLink="false">http://www.ddj.co.za/archives/69/extracting-meta-data-from-smpp-tlvs-with-kannel</guid>
		<description><![CDATA[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&#8217;s using the new Kannel meta data features which are in the current CVS branch. These are scheduled [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8217;s using the new Kannel meta data features which are in the current CVS branch.</p>
<p>These are scheduled for the 1.5.0 stable release of Kannel, so for now you&#8217;ll need to do a CVS checkout of the main branch (as described in my previous posts).</p>
<p>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 &#8216;smpp-tlv&#8217; group, you simply need to specify an additional parameter in your smsbox request. This parameter is named &#8216;meta-data&#8217;. The format for this variable is &#8216;?&lt;bind_type&gt;?&lt;dataset&gt;&#8217; currently the only supported bind type is &#8216;smpp&#8217; but it was done this way to allow future support.</p>
<p>The dataset argument, is a URL encoded key/value pair string. So for these tests I have configured a smpp-tlv group called &#8216;my-custom-var&#8217;. In order to set this, I need to build a string like this for meta-data purposes.</p>
<p><code><br />?smpp?my-custom-var=This+is+a+cool+var<br /></code></p>
<p>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.</p>
<p>So just to demonstrate, using PHP how you would build this string, you would use.</p>
<p><code></p>
<p>$bind_type = "smpp";<br />$my_custom_var = "This is a cool var";<br />$meta_data = "?".$bind_type."?my-custom-var=".urlencode($my_custom_var);<br />/* Now we need to urlencode this string */<br />$meta_data = urlencode($meta_data);<br />/* So URL would look like */<br />/* cgi-bin/sendsms?to=...&amp;from=...&amp;meta-data=$meta_data */</p>
<p></code></p>
<p>So now, when you set this to smsbox, it will be sent via the smpp bind as a TLV. Easy!</p>
<p>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.</p>
<p><code></p>
<p>/* This function will take the meta-data string and return an associative array */<br />function parse_metadata($var) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $pos = strpos($var, "?", 1) + 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Simply stripping out bind type 'smpp', this can be modified if you need it <img src='http://www.ddj.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  */<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var = substr($var, $pos);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $data = parse_str($var, $out);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $out;<br />}</p>
<p>/* Example: */<br />$meta_data = parse_metadata($_GET['meta-data']);</p>
<p>echo "My custom var = ".$meta_data['my-custom-var'];</p>
<p></code></p>
<p>I hope this helps you with your SMPP TLV requirements. Good luck, don&#8217;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.</p>
<p>Technorati Tags: <a class="performancingtags" href="http://technorati.com/tag/Kannel" rel="tag">Kannel</a>, <a class="performancingtags" href="http://technorati.com/tag/SMPP" rel="tag">SMPP</a>, <a class="performancingtags" href="http://technorati.com/tag/TLV" rel="tag">TLV</a>, <a class="performancingtags" href="http://technorati.com/tag/Kannel%20Support" rel="tag">Kannel Support</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ddj.co.za/archives/71/extracting-meta-data-from-smpp-tlvs-with-kannel/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
