How to install a Sendible service using the API

Step 1: Retrieve the available service groups

To get started, you'll need to retrieve all the available service groups. You can do this using the Get Available Service Groups API endpoint.

The result set contains an array of services and each service has a connection_url.

{
    "service_groups": [{
        "services": [{
            "id": 19,
            "title": "Facebook Fan Page",
            "connection_url": "\/api\/v2\/connect?service_id=19",
            "description": "Post updates to your Facebook Fan Pages.",
            "icon": "https:\/\/snd-assets.s3.amazonaws.com\/icons\/somicro\/facebook.png"
        }, {
            "id": 15863,
            "title": "Facebook Page Loader",
            "connection_url": "\/api\/v2\/connect?service_id=15863",
            "description": "Bulk import multiple Facebook Pages or reconnect pages you've already added. ",
            "icon": "https:\/\/snd-assets.s3.amazonaws.com\/icons\/somicro\/facebook.png"
        }, {
            "id": 17384,
            "title": "Facebook Reconnect",
            "connection_url": "\/api\/v2\/connect?service_id=17384",
            "description": "Reconnect the Facebook Pages you've already added to your account.",
            "icon": "https:\/\/snd-assets.s3.amazonaws.com\/icons\/somicro\/facebook.png"
        }, {
            "id": 29,
            "title": "Facebook Group",
            "connection_url": "\/api\/v2\/connect?service_id=29",
            "description": "Post updates to the walls of any of your Facebook Groups.",
            "icon": "https:\/\/s3.amazonaws.com\/snd-assets\/icons\/services\/facebook\/2.png"
        }
]

Step 2: Open a window to the service setup screen

You'll need to open a window redirecting the user to the API host concatenated to the connection url.

For example, using the results above, if a user wants to add a Facebook Fan Page service, you would use: window.open("https://api.sendible.com/api/v2/connect?service_id=19");

You should add an event listener to your page to receive a notification when the services has been added, similar to the following:

window.addEventListener("message", receiveMessage, false);

function receiveMessage(event) 
{ 
  if (event.origin !== api_url)
  { 
    return; 
  } 
  else { 
    console.log(event); alert(event.data.status); 
  } 
} 

Once the service has been added, the window will be closed and the parameters will be passed back to your calling page.