<?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>Talk Unafraid &#187; clickatell</title>
	<atom:link href="http://www.talkunafraid.co.uk/tag/clickatell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.talkunafraid.co.uk</link>
	<description>The (occasionally coherent) ramblings of a geek</description>
	<lastBuildDate>Sat, 07 Jan 2012 22:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Making the Clickatell gem do your bidding</title>
		<link>http://www.talkunafraid.co.uk/2009/05/making-the-clickatell-gem-do-your-bidding/</link>
		<comments>http://www.talkunafraid.co.uk/2009/05/making-the-clickatell-gem-do-your-bidding/#comments</comments>
		<pubDate>Fri, 29 May 2009 23:06:31 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Code Snippets and Examples]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[clickatell]]></category>
		<category><![CDATA[monkeypatching]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=342</guid>
		<description><![CDATA[For a project which will be released to the public next weekend and should start appearing on blogs in the next week (and which could be _huge_), we needed the Clickatell gem from Luke Redpath to pass some other parameters to Clickatell to handle our custom sender ID and callback options. I&#8217;m not quite sure [...]]]></description>
			<content:encoded><![CDATA[<p>For a project which will be released to the public next weekend and should start appearing on blogs in the next week (and which could be _huge_), we needed the Clickatell gem from Luke Redpath to pass some other parameters to Clickatell to handle our custom sender ID and callback options. I&#8217;m not quite sure why, but the original gem filters out all but two of the configuration options you can pass it.</p>
<p>Fortunately, thanks to Ruby we could work around it with a nasty monkeypatch- namely, overriding the method in it&#8217;s entirety in environment.rb:</p>
<div class="geshi no ruby">
<div class="head"># Monkeypatch for Clickatell gem to allow callback param</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw1">module</span> Clickatell</div>
</li>
<li class="li1">
<div class="de1">  <span class="kw1">class</span> API</div>
</li>
<li class="li1">
<div class="de1">    <span class="kw1">def</span> send_message<span class="br0">&#40;</span>recipient, message_text, opts=<span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">      response = execute_command<span class="br0">&#40;</span><span class="st0">&#39;sendmsg&#39;</span>, <span class="st0">&#39;http&#39;</span>,</div>
</li>
<li class="li1">
<div class="de1">        <span class="br0">&#123;</span>:to <span class="sy0">=&gt;</span> recipient, <span class="re3">:text</span> <span class="sy0">=&gt;</span> message_text<span class="br0">&#125;</span>.<span class="me1">merge</span><span class="br0">&#40;</span>opts<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">      <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">      parse_response<span class="br0">&#40;</span>response<span class="br0">&#41;</span><span class="br0">&#91;</span><span class="st0">&#39;ID&#39;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">    <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">  <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
</ol>
</div>
<p>Not pretty, but it does the job. You can now pass in all the options you need:</p>
<pre lang="ruby">api.send_message(mobile_number, content, :from => 'SenderID', :callback => 3)</pre>
<p>Again, entirely confused as to why the gem filters all options out. I&#8217;ll prod Luke Redpath and see if there&#8217;s some reason to it, and if there&#8217;s not perhaps this can get fixed to avoid the monkeypatching.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2009/05/making-the-clickatell-gem-do-your-bidding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

