The ReNotifier API

ReNotifier currently supports an API for importing users that have already authorized your Facebook app to ReNotifier.

You are required to update the ReNotifier database if users are authorizing your app in ways other than through the Facebook App canvas page. If your users are authorizing your site via a login with Facebook button, you should implement calls to our API in order to synchronize the ReNotifier database with your app's user database. You may think of this the same as updating your contact list with your mass mail sending service - except for Facebook notifications of course.

API endpoints

The ReNotifier API is very simple and can be accessed either programmatically or via a web interface.

Importing users

The endpoint for importing users is available at:

https://renotifier.com/api/import

The API will determine whether you are trying to access it from a browser capable of displaying HTML or from some other source and return an appropriate response. If you wish to force it to JSON use the following address:

https://renotifier.com/api/import.json

This API endpoint accepts two actions: GET and POST.

The GET action returns a list of previous imports with statuses that can be examined - similar to the table at the import users page.

The POST accepts two fields in the data: facebook_app_id and facebook_ids, where:

Remember: Only users who have already authorised your app will be imported. Duplicate instances of User IDs will be automatically removed and invalid User IDs will be discarded. Importing does not send any confirmation message to users.

API authorization

The ReNotifier API allows two methods of authorization: by entering a username and password with each API call, or by providing an authorization token with the request headers. Both of these methods are explained in this section.

Token authorization (recommended)

To authenticate with the API you may use a token key. The token key should be included in the Authorization HTTP header. The key should be prefixed by the string literal "Token", with whitespace separating the two strings. For example:

Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b

In the following examples a sample access token will be used. To obtain yours, please register.

<?php

   $token = '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b';

   $endpoint_url = 'https://renotifier.com/api/import';
   $curl = curl_init($endpoint_url);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl, CURLOPT_HTTPHEADER, Array("Authorization: Token ".$token));
   $curl_response = curl_exec($curl);
   curl_close($curl);

   $result = json_decode($curl_response);

   print_r($result);

?>
import urllib2
import json

token = '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

opener = urllib2.build_opener()
opener.addheaders = [('Authorization', 'Token '+token)]
result = opener.open('https://renotifier.com/api/import').read()
result = json.loads(result)
print result
require 'net/https'
require 'json'
http = Net::HTTP.new('renotifier.com', 443)
http.use_ssl = true
http.start do |http|
   req = Net::HTTP::Get.new('/api/import')

   req.add_field 'Authorization', 'Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

   resp, data = http.request(req)
   result = JSON.parse(resp.body)
   puts result
end
curl -H "Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" https://renotifier.com/api/import

Authorization with username and password

Authorization with your email and password is also supported although it is discouraged as it requires you to have your password stored in plaintext in your codebase. You may use this if your codebase is sufficiently secure.

<?php

   $username = 'your_email';
   $password = 'your_password';

   $endpoint_url = 'https://renotifier.com/api/import';
   $curl = curl_init($endpoint_url);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl, CURLOPT_USERPWD, $username.":".$password);
   $curl_response = curl_exec($curl);
   curl_close($curl);

   $result = json_decode($curl_response);

   print_r($result);

?>
import urllib2
import json

renotifier_user = 'your_email'
renotifier_pass = 'your_password'

password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(
    None, 'https://renotifier.com/', renotifier_user, renotifier_pass
)
auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
opener = urllib2.build_opener(auth_handler)
result = opener.open('https://renotifier.com/api/import').read()
result = json.loads(result)
print result
require 'net/https'
require 'json'
http = Net::HTTP.new('renotifier.com', 443)
http.use_ssl = true
http.start do |http|
   req = Net::HTTP::Get.new('/api/import')

   req.basic_auth 'your_email', 'your_password'

   resp, data = http.request(req)
   result = JSON.parse(resp.body)
   puts result
end
curl -u your_email:your_password https://renotifier.com/api/import

Importing users with the API - code samples

In order to import a user with the ID 1234 to a Facebook App with ID 5678 we need to do the following API call (with the token authorization)

<?php

   $token = '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b';

   $facebook_app_id = '5678';
   $facebook_ids = '1234'; //can be one or more IDs, comma or new line separated

   $data = array('facebook_app_id' => $facebook_app_id, 'facebook_ids' => $facebook_ids);

   $endpoint_url = 'https://renotifier.com/api/import';
   $curl = curl_init($endpoint_url);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl, CURLOPT_HTTPHEADER, Array("Authorization: Token ".$token));
   curl_setopt($curl, CURLOPT_POST, 1);
   curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
   $curl_response = curl_exec($curl);
   curl_close($curl);

   //you do not need to print results, this is just for debugging purposes
   $result = json_decode($curl_response);
   print_r($result);

?>
import urllib2
import urllib
import json

token = '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

facebook_app_id = '5678'
facebook_ids = '1234'

values = {'facebook_app_id':facebook_app_id,'facebook_ids':facebook_ids}

opener = urllib2.build_opener()
opener.addheaders = [('Authorization', 'Token '+token)]
try:
    result = opener.open('https://renotifier.com/api/import',urllib.urlencode(values)).read()
except urllib2.HTTPError, error:
    result = error.read()

result = json.loads(result) # you do not need to do this, this is just for debugging
print result # just for debugging
require 'net/https'
require 'json'
http = Net::HTTP.new('renotifier.com', 443)
http.use_ssl = true
http.start do |http|
   req = Net::HTTP::Post.new('/api/import')

   req.add_field 'Authorization', 'Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

   resp, data = http.request(req,'facebook_app_id=5678&facebook_ids=1234')
   result = JSON.parse(resp.body)
   puts result
end
curl -H "Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" --data "facebook_app_id=5678&facebook_ids=1234" https://renotifier.com/api/import

If you require more help with calling the ReNotifier API please contact our support, we will be happy to assist you.