Skip to Content

Mediaburst Gem

Posted on 2 mins read

In order to make it stupidly simple to integrate with the Mediaburst API, I was asked to develop a Ruby Gem that could provide an easy to use interface for Ruby developers.

Installation

Install the gem as normal:

{% highlight bash %} sudo gem install mediaburst {% endhighlight %}

The Mediaburst gem also relies on Nokogiri for XML parsing.

Usage

Create an instance of the Mediaburst client:

{% highlight ruby %} client = Mediaburst::API.new(‘username’, ‘password’) {% endhighlight %}

Send an SMS:

{% highlight ruby %} response = client.send_message(‘441234567890’, ‘My test message’) {% endhighlight %}

Send a message to several numbers:

{% highlight ruby %} response = client.send_message([‘441234567890’, ‘441234567891’, ‘441234567892’], ‘My test message’) {% endhighlight %}

Send a long message to several numbers using the concat option:

{% highlight ruby %} options = { :concat => 3 }

response = client.send_message([‘441234567890’, ‘441234567891’, ‘441234567892’, ‘44’], SOME_LONG_MESSAGE, options) {% endhighlight %}

Check the response for errors:

{% highlight ruby %} y response => — “441234567890”: true “441234567891”: true “441234567892”: true “44”: 10 {% endhighlight %}

On error, the value of the key referenced by the number will equal the error code returned from Mediaburst.

Development

The source for the gem is hosted on GitHub for you to peruse, fork and contribute to.

To enable us to easily manage your contributions, please submit your pull requests as single commits that include tests to show your changes working as normal. Please do not change the version number - we’ll take care of that as we merge your changes.

License

Copyright © 2011 Matthew Hall, released under the ISC license. All trademarks and IP remain the property of their respective owners.