Blitz Alert

Sending Quick Push Notifications
Back Home

REST API Documentation

Blitz Alert uses easy and simple REST APIs for sending push notifications to Android devices.

Generate Token
Description • Register a new user to start receiving push messages. You need to provide a unique userid with this call, and the server will return a token. This token must then be given to the user to enter into their BLITZ ALERT Android app. Once this has been done you can start pushing messages to that user's device.
• Only done once per user.
This can also be done via the website
Method HTTP GET
Request http://api.blitzalert.co.za/code?service=ServiceId&user=UserId&auth=ServiceKey
Response
(As JSON)
{
   "code": "XXXXXX"
}
This token can then be given to the user to enter in their Android app to start receiving messages.
CURL Example curl -X GET "http://api.blitzalert.co.za/code?service=ServiceId&user=UserId&auth=ServiceKey"
PHP Example $url = "http://api.blitzalert.co.za/code?service=$serviceid&user=$userid&auth=$key";
$res = file_get_contents( $url );
$json = json_decode( $res, true );
if ((!is_null($json)) && (isset($json['code']))) {
     $code = $json['code'];
}


Send Message
Description • Send a Message to the user's Android device. You need to specify the specific user the message should go to.
• You can specify multiple userid's (comma separated) to send the same message to multiple users.
• Maximum message length is 1024 characters.
• Messages are only kept on our servers until delivered, then its permanently deleted.
Method HTTP POST
Request http://api.blitzalert.co.za/send?service=ServiceId&user=UserId&auth=ServiceKey
The body of the HTTP request contains the message to be sent.
Response
(As JSON)
[
   {
     "user": "USERID",
     "status": 200
   }
]
It will return a JSON array containing all the users the message was sent too, each with their own status code. This is just to show success or failure of delivery to the BLITZ ALERT server and not actual delivery to the user's device.
CURL Example curl -X POST --header "Content-Type: text/plain" -d "Your Message Here!" "http://api.blitzalert.co.za/send?service=ServiceId&user=UserId&auth=ServiceKey"
PHP Example $message = "Your Message Here!";
$url = "http://api.blitzalert.co.za/send?service=$serviceid&user=$userid&auth=$key";
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $message );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 5 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
$res = curl_exec( $ch );
curl_close( $ch );


Broadcast a Message
Description • Send a message to all users registered for your service.
• Maximum message length is 1024 characters.
• Messages are only kept on our servers until delivered, then its permanently deleted.
Method HTTP POST
Request http://api.blitzalert.co.za/broadcast?service=ServiceId&auth=ServiceKey
The body of the HTTP request contains the message to be sent.
Response
(As JSON)
{
   "messages": XYZ
}
The response indicates the number of users to which the message was sent. This shows deliveries on the BLITZ ALERT server and not actual delivery to the user's device.
CURL Example curl -X POST --header "Content-Type: text/plain" -d "Your Message Here!" "http://api.blitzalert.co.za/broadcast?service=ServiceId&auth=ServiceKey"
PHP Example $message = "Your Message Here!";
$url = "http://api.blitzalert.co.za/broadcast?service=$serviceid&auth=$key";
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $message );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 5 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
$res = curl_exec( $ch );
curl_close( $ch );


Verify a User
Description • Verify if the user is currently registered for the service.
Method HTTP GET
Request http://api.blitzalert.co.za/verify?service=ServiceId&user=UserId&auth=ServiceKey
Response
(As JSON)
{
   "user": "USERID",
   "status": 200
}
A status of 200 indicates that the user is registered, and a status of 412 indicates they are not.
CURL Example curl -X GET "http://api.blitzalert.co.za/verify?service=ServiceId&user=UserId&auth=ServiceKey"
PHP Example $url = "http://api.blitzalert.co.za/verify?service=$serviceid&user=$userid&auth=$key";
$res = file_get_contents( $url );
$json = json_decode( $res, true );
if ((!is_null($json)) && (isset($json['status']))) {
     $registered = ( $json['status'] == 200 );
}


REST API    |    Integrations    |    Contact Us    |    Terms & Conditions

Developed by Inventit 2015