Skip to content

Instantly share code, notes, and snippets.

@treeder
Created January 28, 2012 00:46
Show Gist options
  • Save treeder/1691843 to your computer and use it in GitHub Desktop.
Save treeder/1691843 to your computer and use it in GitHub Desktop.
IronMQ Client Code for Titanium Mobile Developers
//Then in the main "app.js" (or wherever) call it like this:
var HTTPironmq = require('iron_mq');
HTTPironmq.call({
paramsJSON : {
messages : [
{
"body": "This is my message 1.",
"timeout": 30,
"delay": 2,
"expires_in": 86400
}
]
},
timeout : 10000
});
exports.call = function (options) {
var xhr = Titanium.Network.createHTTPClient();
var paramsStr = JSON.stringify(options.paramsJSON);
xhr.setTimeout(options.timeout);
xhr.onerror = options.error;
//if and when response comes back the success function is called (need to handle reading the response msg here
xhr.onload = function(){
Titanium.API.info("xhr response text was: " + xhr.responseText);
};
xhr.open('POST', 'https://mq-aws-us-east-1.iron.io/1/projects/4f20a1135023e823541111bc/queues/my_queue/messages', true);
xhr.setRequestHeader('Authorization','OAuth ' + 'vNj11tk3TwzjW1z11115a7c35dM');
xhr.setRequestHeader('User-Agent','IronMQ Client');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(paramsStr);
};
@KDLDevelop
Copy link

var HTTPironmq = require('HTTPironmq');

should be:

var HTTPironmq = require('iron_mq');

@treeder
Copy link
Author

treeder commented Jan 29, 2012

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment