Sms Campaign
Sms Campaign
PHP

Introduction

Do you know the SMS Campaign App? Well this is the API behind the app we all know and love. It allows you to manage and send out campaigns programatically, just like the app does.

campaigns

getAllCampaign

Get all campaigns

https://api.cmtelecom.com/v1.0/campaigns

GET Parameters

name in description required type
X-CM-PRODUCTTOKEN header The product token associated with your CMDirect account true string

Responses

http status description
200 Successful
400 Bad request
500 Internal server error

curl -i https://api.cmtelecom.com/v1.0/campaigns
     -X GET
     -H "Content-Type: application/json"
<?php
  // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required
  $parameters = array(
    'X-CM-PRODUCTTOKEN' => 'X-CM-PRODUCTTOKEN'
  );

  $url = 'https://api.cmtelecom.com/v1.0/campaigns';

  $ch = curl_init();
  curl_setopt_array($ch, array(
     CURLOPT_URL            => $url,
     CURLOPT_HTTPHEADER     => array(
                                 'Content-Type: application/json',
                                 'X-CM-PRODUCTTOKEN: '.$params['X-CM-PRODUCTTOKEN']
                                 ),
     CURLOPT_HEADER       => TRUE,
     CURLOPT_RETURNTRANSFER => true
    )
  );
  $result = curl_exec($ch);
  $HeaderInfo = curl_getinfo($ch);
  $HeaderSize=$HeaderInfo['header_size'];
  $Body = trim(mb_substr($result, $HeaderSize));
  $ResponseHeader = explode('n',trim(mb_substr($result, 0, $HeaderSize)));
  unset($ResponseHeader[0]);
  $Headers = array();
  foreach($ResponseHeader as $line){
      list($key,$val) = explode(':',$line,2);
      $Headers[strtolower($key)] = trim($val);
  }

  var_dump( array(
      'Body' => $Body,
      'Headers' => $Headers
  ));
?>

createCampaign

Create a campaign

https://api.cmtelecom.com/v1.0/campaigns

POST Parameters

name in description required type schema
X-CM-PRODUCTTOKEN header The product token associated with your CMDirect account true string
body body true object
  • {
    • "required" : [
      • "name",
      • "group",
      • "sender",
      • "body"
      ], "properties" : {
      • "id" : "integer",
      • "name" : "string",
      • "group" : "integer",
      • "sender" : "string",
      • "body" : "string",
      • "conversion_link" : "string",
      • "app_key" : "string"
      }, "xml" : {
      • "name" : "Campaign"
      }
    }

Responses

http status description
200 Created campaign
400 Invalid/Incomplete request
404 Not found
500 Internal server error

curl -i https://api.cmtelecom.com/v1.0/campaigns
     -X POST
     -H "Content-Type: application/json"
     -d "{
 'required' : [
  'name',
  'group',
  'sender',
  'body'
 ],
 'properties' : {
  'id' : 'integer',
  'name' : 'string',
  'group' : 'integer',
  'sender' : 'string',
  'body' : 'string',
  'conversion_link' : 'string',
  'app_key' : 'string'
 },
 'xml' : {
  'name' : 'Campaign'
 }
}"
<?php
  // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required
  $parameters = array(
    'data' => json_encode(array(
               "required": [
                "name",
                "group",
                "sender",
                "body"
               ],
               "properties": array(
                "id" => "integer",
                "name" => "string",
                "group" => "integer",
                "sender" => "string",
                "body" => "string",
                "conversion_link" => "string",
                "app_key" => "string"
               ),
               "xml": array(
                "name" => "Campaign"
               )
              )          ),
    'X-CM-PRODUCTTOKEN' => 'X-CM-PRODUCTTOKEN'
  );

  $url = 'https://api.cmtelecom.com/v1.0/campaigns';

  $ch = curl_init();
  curl_setopt_array($ch, array(
     CURLOPT_URL            => $url,
     CURLOPT_HTTPHEADER     => array(
                                 'Content-Type: application/json',
                                 'X-CM-PRODUCTTOKEN: '.$params['X-CM-PRODUCTTOKEN']
                                 ),
     CURLOPT_HEADER       => TRUE,
     CURLOPT_POST           => true,
     CURLOPT_POSTFIELDS     => $data,
     CURLOPT_RETURNTRANSFER => true
    )
  );
  $result = curl_exec($ch);
  $HeaderInfo = curl_getinfo($ch);
  $HeaderSize=$HeaderInfo['header_size'];
  $Body = trim(mb_substr($result, $HeaderSize));
  $ResponseHeader = explode('n',trim(mb_substr($result, 0, $HeaderSize)));
  unset($ResponseHeader[0]);
  $Headers = array();
  foreach($ResponseHeader as $line){
      list($key,$val) = explode(':',$line,2);
      $Headers[strtolower($key)] = trim($val);
  }

  var_dump( array(
      'Body' => $Body,
      'Headers' => $Headers
  ));
?>

getCampaign

Get a single campaign

https://api.cmtelecom.com/v1.0/campaigns/{id}

GET Parameters

name in description required type
X-CM-PRODUCTTOKEN header The product token associated with your CMDirect account true string
id path Identifier true integer

Responses

http status description
200 Successful
404 Campaign not found
500 Internal server error

curl -i https://api.cmtelecom.com/v1.0/campaigns/{id}
     -X GET
     -H "Content-Type: application/json"
<?php
  // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required
  $parameters = array(
    'id' => 10,
    'X-CM-PRODUCTTOKEN' => 'X-CM-PRODUCTTOKEN'
  );

  $url = 'https://api.cmtelecom.com/v1.0/campaigns/'
         .$id;

  $ch = curl_init();
  curl_setopt_array($ch, array(
     CURLOPT_URL            => $url,
     CURLOPT_HTTPHEADER     => array(
                                 'Content-Type: application/json',
                                 'X-CM-PRODUCTTOKEN: '.$params['X-CM-PRODUCTTOKEN']
                                 ),
     CURLOPT_HEADER       => TRUE,
     CURLOPT_RETURNTRANSFER => true
    )
  );
  $result = curl_exec($ch);
  $HeaderInfo = curl_getinfo($ch);
  $HeaderSize=$HeaderInfo['header_size'];
  $Body = trim(mb_substr($result, $HeaderSize));
  $ResponseHeader = explode('n',trim(mb_substr($result, 0, $HeaderSize)));
  unset($ResponseHeader[0]);
  $Headers = array();
  foreach($ResponseHeader as $line){
      list($key,$val) = explode(':',$line,2);
      $Headers[strtolower($key)] = trim($val);
  }

  var_dump( array(
      'Body' => $Body,
      'Headers' => $Headers
  ));
?>

updateCampaign

Update a campaign

https://api.cmtelecom.com/v1.0/campaigns/{id}

PUT Parameters

name in description required type schema
X-CM-PRODUCTTOKEN header The product token associated with your CMDirect account true string
body body true object
  • {
    • "required" : [
      • "name",
      • "group",
      • "sender",
      • "body"
      ], "properties" : {
      • "id" : "integer",
      • "name" : "string",
      • "group" : "integer",
      • "sender" : "string",
      • "body" : "string",
      • "conversion_link" : "string",
      • "app_key" : "string"
      }, "xml" : {
      • "name" : "Campaign"
      }
    }

Responses

http status description
200 Updated campaign
400 Invalid/Incomplete request
404 Group/Campaign not found
500 Internal server error

curl -i https://api.cmtelecom.com/v1.0/campaigns/{id}
     -X PUT
     -H "Content-Type: application/json"
     -d "{
 'required' : [
  'name',
  'group',
  'sender',
  'body'
 ],
 'properties' : {
  'id' : 'integer',
  'name' : 'string',
  'group' : 'integer',
  'sender' : 'string',
  'body' : 'string',
  'conversion_link' : 'string',
  'app_key' : 'string'
 },
 'xml' : {
  'name' : 'Campaign'
 }
}"
<?php
  // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required
  $parameters = array(
    'data' => json_encode(array(
               "required": [
                "name",
                "group",
                "sender",
                "body"
               ],
               "properties": array(
                "id" => "integer",
                "name" => "string",
                "group" => "integer",
                "sender" => "string",
                "body" => "string",
                "conversion_link" => "string",
                "app_key" => "string"
               ),
               "xml": array(
                "name" => "Campaign"
               )
              )          ),
    'X-CM-PRODUCTTOKEN' => 'X-CM-PRODUCTTOKEN'
  );

  $url = 'https://api.cmtelecom.com/v1.0/campaigns/'
         .$id;

  $ch = curl_init();
  curl_setopt_array($ch, array(
     CURLOPT_URL            => $url,
     CURLOPT_HTTPHEADER     => array(
                                 'Content-Type: application/json',
                                 'X-CM-PRODUCTTOKEN: '.$params['X-CM-PRODUCTTOKEN']
                                 ),
     CURLOPT_HEADER       => TRUE,
     CURLOPT_CUSTOMREQUEST  => 'PUT',
     CURLOPT_POST           => true,
     CURLOPT_POSTFIELDS     => $data,
     CURLOPT_RETURNTRANSFER => true
    )
  );
  $result = curl_exec($ch);
  $HeaderInfo = curl_getinfo($ch);
  $HeaderSize=$HeaderInfo['header_size'];
  $Body = trim(mb_substr($result, $HeaderSize));
  $ResponseHeader = explode('n',trim(mb_substr($result, 0, $HeaderSize)));
  unset($ResponseHeader[0]);
  $Headers = array();
  foreach($ResponseHeader as $line){
      list($key,$val) = explode(':',$line,2);
      $Headers[strtolower($key)] = trim($val);
  }

  var_dump( array(
      'Body' => $Body,
      'Headers' => $Headers
  ));
?>

sendCampaign

Send a campaign

https://api.cmtelecom.com/v1.0/campaigns/{id}/send

POST Parameters

name in description required type schema
X-CM-PRODUCTTOKEN header The product token associated with your CMDirect account true string
id path The campaign identifier true integer
date body The date in ISO8601 format to send the campaign on false object
  • {
    • "date" : "string"
    }

Responses

http status description
200 Campaign has been sent
400 Invalid/Incomplete request
404 Group/Campaign not found
500 Internal server error

curl -i https://api.cmtelecom.com/v1.0/campaigns/{id}/send
     -X POST
     -H "Content-Type: application/json"
     -d "{
 'date' : 'string'
}"
<?php
  // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required
  $parameters = array(
    'id' => 10,
    'data' => json_encode(array(
               "date" => "string"
              )          ),
    'X-CM-PRODUCTTOKEN' => 'X-CM-PRODUCTTOKEN'
  );

  $url = 'https://api.cmtelecom.com/v1.0/campaigns/'
         .$id
         .'/send';

  $ch = curl_init();
  curl_setopt_array($ch, array(
     CURLOPT_URL            => $url,
     CURLOPT_HTTPHEADER     => array(
                                 'Content-Type: application/json',
                                 'X-CM-PRODUCTTOKEN: '.$params['X-CM-PRODUCTTOKEN']
                                 ),
     CURLOPT_HEADER       => TRUE,
     CURLOPT_POST           => true,
     CURLOPT_POSTFIELDS     => $data,
     CURLOPT_RETURNTRANSFER => true
    )
  );
  $result = curl_exec($ch);
  $HeaderInfo = curl_getinfo($ch);
  $HeaderSize=$HeaderInfo['header_size'];
  $Body = trim(mb_substr($result, $HeaderSize));
  $ResponseHeader = explode('n',trim(mb_substr($result, 0, $HeaderSize)));
  unset($ResponseHeader[0]);
  $Headers = array();
  foreach($ResponseHeader as $line){
      list($key,$val) = explode(':',$line,2);
      $Headers[strtolower($key)] = trim($val);
  }

  var_dump( array(
      'Body' => $Body,
      'Headers' => $Headers
  ));
?>