The Hipmob REST API now talks directly with your app's backend.
The easiest way to add messaging to your app, now integrates with PHP, Node.JS, and Python. See some examples

What can you do with the Hipmob REST API?


Send support messages to your users, including text, images & audio.


Dynamically manage your users' buddy lists.


Check your users' status(es) to see if they're online, offline, or mid-conversation.

And anything else that requires scalable, real-time messaging for your app.

iPhone, iPad and Android Ready

Plug and play in 15 minutes for your
iPhone, iPad (and Android) app(s).

Send text, images & audio

Focus on your app, we'll do the heavy lifting.

Cloud-hosted, XMPP Backbone

Real-time & async messaging on a scalable XMPP infrastructure.

TRY HIPMOB FOR FREE NOW

or call us at (650) 762-6513

EXAMPLE CODE: Sending Picture Messages

Description
Sends a picture message to the specified device.
URL Structure
https://api.hipmob.com/apps/{application ID}/devices/{host application identifier}/messages
Request Method
POST
Since
1.1
Request Content-Type
image/png OR image/jpeg OR image/gif
Request Headers
Name Required Quantity Description
Content-Length Yes Exactly Once The size of the picture to be sent, in bytes.
X-Hipmob-Autocreate No At most once The text true if the message should be sent regardless of whether or not the target host application identifier has been seen yet.
Post Body
The binary data (NOT base64-encoded) of the picture to send.
Returns
200
Message sent.
Errors
400
No application was specified in the URL.
400
No host application identifier was specified in the URL.
400
No content length specified.
402
The request failed despite valid authentication.
404
The specified application could not be found.
404
No device with the specified host application identifier could be found.
415
Content-type not supported on that device.
Notes
The Hipmob API handles queueing messages for devices that have not yet connected to the Hipmob communication network: the messages are preserved until the device actually connects. To ensure mistakes aren't made when specifying the target host identifier, the X-Hipmob-Autocreate request header must be provided if the target host identifier may not have been in contact with the Hipmob communication network yet. If this header is not provided and the device has not been seen a 404 error will be returned, otherwise the message will be queued and delivered whenever the device connects.
Depending on the device's configuration the device may not provide support for picture messaging: if that information is available the API will reject the request with a 415 error.
Example Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// copy the lib folder from the PHP library into the current directory, then set the required
// environment variables
if(!isset($_SERVER['hipmob_username'])){
echo "Please provide the username as an environment variable.\r\n";
return;
}
if(!isset($_SERVER['hipmob_apikey'])){
echo "Please provide the API key as an environment variable.\r\n";
return;
}
if(!isset($_SERVER['hipmob_app'])){
echo "Please provide the application ID as an environment variable.\r\n";
return;
}
 
// update this variable to be the host application identifier you're interested in
$deviceid = "{specific device id}";
 
// set this to the path of the PNG, GIF or JPEG image to be sent
$picture = "{picture file path}";
 
// specify the image mime type: acceptable values are image/jpeg,
// image/gif and image/png
$picture_mime_type = "image/jpeg";
 
require_once(dirname(__FILE__) . 'lib/Hipmob.php');
$hipmob = new Hipmob($_SERVER['hipmob_username'], $_SERVER['hipmob_apikey']);
 
// passing false for the third parameter prevents the library from hitting the server
// to verify that the device exists: if you're certain the device exists then this
// is more efficient
$device = $hipmob->get_device($_SERVER['hipmob_app'], $deviceid, false);
 
print_r($device->send_picture_message($picture, $picture_mime_type));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# install Hipmob using "pip install hipmob", then set the required environment variables
import sys, os, hipmob
 
if 'hipmob_username' not in os.environ:
print "Please provide the username as an environment variable.";
sys.exit()
 
if 'hipmob_apikey' not in os.environ:
print "Please provide the API key as an environment variable.";
sys.exit()
 
if 'hipmob_app' not in os.environ:
print "Please provide the application ID as an environment variable.";
sys.exit()
 
# update this variable to be the host application identifier you're interested in
deviceid = "{specific device id}"
 
# set this to the path of the PNG, GIF or JPEG image to be sent
picture = "{picture file path}";
 
# specify the image mime type: acceptable values are image/jpeg,
# image/gif and image/png
picture_mime_type = "image/jpeg";
 
hipmob = hipmob.Hipmob(os.environ['hipmob_username'], os.environ['hipmob_apikey']);
res = hipmob.get_device(os.environ['hipmob_app'], deviceid)
print "Sending message: "+str(res.send_picture_message(picture, picture_mime_type))+"."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// install Hipmob using "npm install hipmob", then set the required environment variables
if(!('hipmob_username' in process.env)){
console.log("Please provide the username as an environment variable.");
return;
}
if(!('hipmob_apikey' in process.env)){
console.log("Please provide the API key as an environment variable.");
return;
}
if(!('hipmob_app' in process.env)){
console.log("Please provide the application ID as an environment variable.");
return;
}
 
// update this variable to be the host application identifier you're interested in
var deviceid = "{specific device id}";
 
var hipmob = require("hipmob");
var handle = hipmob(process.env.hipmob_username, process.env.hipmob_password);
var dev = handle.get_device(process.env.hipmob_app, deviceid, false);
 
// set this to the name of the file to send
var image = "/home/me/funnypicture.png";
 
// you can pass it either a file or a Buffer: it can not be a stream because we must know
// the Content-Length to successfully send the file.
dev.send_picture_message(image, "image/png", function(err){
if(!err){ console.log("Message sent."); }else{ console.log(err); }
});