Specialty messaging services tailored towards your business
The generated code has dependencies over external libraries like UniRest. These dependencies are defined in the composer.json
file that comes with the SDK.
To resolve these dependencies, we use the Composer package manager which requires PHP greater than 5.3.2 installed in your system.
Visit https://getcomposer.org/download/ to download the installer file for Composer and run it in your system.
Open command prompt and type composer --version
. This should display the current version of the Composer installed if the installation was successful.
- Using command line, navigate to the directory containing the generated files (including
composer.json
) for the SDK. - Run the command
composer install
. This should install all the required dependencies and create thevendor
directory in your project directory.
CURL used to include a list of accepted CAs, but no longer bundles ANY CA certs. So by default it will reject all SSL certificates as unverifiable. You will have to get your CA's cert and point curl at it. The steps are as follows:
- Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
- Add curl.cainfo = "PATH_TO/cacert.pem" to your php.ini file located in your php installation. “PATH_TO” must be an absolute path containing the .pem file.
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =
The following section explains how to use the TransmitMessage library in a new project.
Open an IDE for PHP like PhpStorm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on Open
in PhpStorm to browse to your generated SDK directory and then click OK
.
Create a new directory by right clicking on the solution name as shown below:
Name the directory as "test"
Add a PHP file to this project
Name it "testSDK"
Depending on your project setup, you might need to include composer's autoloader in your PHP code to enable auto loading of classes.
require_once "../vendor/autoload.php";
It is important that the path inside require_once correctly points to the file autoload.php
inside the vendor directory created during dependency installations.
After this you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
To run your project you must set the Interpreter for your project. Interpreter is the PHP engine installed on your computer.
Open Settings
from File
menu.
Select PHP
from within Languages & Frameworks
Browse for Interpreters near the Interpreter
option and choose your interpreter.
Once the interpreter is selected, click OK
To run your project, right click on your PHP file inside your Test project and click on Run
Unit tests in this SDK can be run using PHPUnit.
- First install the dependencies using composer including the
require-dev
dependencies. - Run
vendor\bin\phpunit --verbose
from commandline to execute tests. If you have installed PHPUnit globally, run tests usingphpunit --verbose
instead.
You can change the PHPUnit test configuration in the phpunit.xml
file.
In order to setup authentication and initialization of the API client, you need the following information.
Parameter | Description |
---|---|
xApiKey | Your Api key |
API client can be initialized as following.
$xApiKey = 'xApiKey'; // Your Api key
$client = new TransmitMessageLib\TransmitMessageClient($xApiKey);
The singleton instance of the ContactsController
class can be accessed from the API Client.
$contacts = $client->getContacts();
Get metadata of all contact lists defined in your account. Metadata includes list names and corresponding descriptions, contact count within each list, created/updated date and time of each list, filters applied on the list (if any) and type of list.
function getLists(
$sort = 'updated_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (relevant field values) |
page | Optional DefaultValue |
The page number of the result to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'updated_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $contacts->getLists($sort, $filters, $page, $limit);
Create a new (Static or Dynamic) contact list. NOTE: Filters are required only in case of a Dynamic List, and are not necessary for a Static List.
function createList($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
List details |
$body = new ContactList();
$result = $contacts->createList($body);
Delete a contact list.
function deleteList($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
List ID |
$id = 'id';
$result = $contacts->deleteList($id);
Add contacts into a static list. NOTE: This end point cannot be used to add contacts into a dynamic list.
function addListContacts(
$id,
$body)
Parameter | Tags | Description |
---|---|---|
id | Required |
Static List ID |
body | Required |
IDs of all contacts to be added to the list (max 100) |
$id = 'id';
$body = new AddToContactList();
$result = $contacts->addListContacts($id, $body);
Remove contacts from a list. NOTE: This endpoint can be used to remove contacts only from a Static list.
function removeListContacts(
$id,
$body)
Parameter | Tags | Description |
---|---|---|
id | Required |
Static List ID |
body | Required |
IDs of all contacts to be removed from the list |
$id = 'id';
$body = new AddToContactList();
$result = $contacts->removeListContacts($id, $body);
Format a valid mobile number from any format to an international format.
function formatNumber($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
Phone Number Object |
$body = new PhoneNumber();
$result = $contacts->formatNumber($body);
Get metadata for a selected contact list.
function getAList($iD)
Parameter | Tags | Description |
---|---|---|
iD | Required |
List ID |
$iD = 'ID';
$result = $contacts->getAList($iD);
Delete a custom contact field
function removeContactField($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
The custom contact field ID |
$id = 'id';
$result = $contacts->removeContactField($id);
Update contact field information
function updateContactField(
$id,
$body)
Parameter | Tags | Description |
---|---|---|
id | Required |
The custom contact field ID |
body | Required |
The custom contact field details (name, type etc.) |
$id = 'id';
$body = new ContactField();
$result = $contacts->updateContactField($id, $body);
Get a list of custom contact fields and corresponding field details (name, type etc.)
function getContactFields()
$result = $contacts->getContactFields();
Create a custom contact field. Input additional relevant parameter values such as decimals for a numeric type field, or values for a list type field etc.
function createContactField($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
Contact field details |
$body = new ContactField();
$result = $contacts->createContactField($body);
Get information of contacts within a contact list.
function getListContacts(
$id,
$sort = 'updated_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
id | Required |
List ID |
sort | Optional DefaultValue |
Sorted by (field name) |
filters | Optional Collection |
Filter by (contact data). Applicable for Static Lists only |
page | Optional DefaultValue |
The page of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$id = 'id';
$sort = 'updated_at';
$filters = array('filters');
$page = 0;
$limit = 25;
$result = $contacts->getListContacts($id, $sort, $filters, $page, $limit);
Get information of all contacts in the TransmitMessage contacts database
function getContacts(
$sort = 'updated_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
The output field to sort the results by |
filters | Optional |
Filter by (field values) |
page | Optional DefaultValue |
The page number of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'updated_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $contacts->getContacts($sort, $filters, $page, $limit);
Get information about a contact in your TransmitMessage contact database
function getAContact($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
Contact Reference number |
$id = 'id';
$result = $contacts->getAContact($id);
Create a new contact or Update details of an existing contact
function createOrUpdateContact(
$contactRef,
$body)
Parameter | Tags | Description |
---|---|---|
contactRef | Required |
Contact reference number |
body | Required |
Contact details |
$contactRef = 'contact_ref';
$body = new Contact();
$result = $contacts->createOrUpdateContact($contactRef, $body);
Remove a contact record
function removeAContact($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
Contact ID |
$id = 'id';
$result = $contacts->removeAContact($id);
The singleton instance of the AccountsController
class can be accessed from the API Client.
$accounts = $client->getAccounts();
Get Account Balance
function getAccountBalance()
$result = $accounts->getAccountBalance();
Get Sender Ids
function getSenderIds(
$sort = 'name',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter results by (field value) |
page | Optional DefaultValue |
The page number of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'name';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $accounts->getSenderIds($sort, $filters, $page, $limit);
The singleton instance of the MMSController
class can be accessed from the API Client.
$mMS = $client->getMMS();
Cancel an MMS Campaign. NOTE: Can only cancel campaigns in SCHEDULED or VALIDATING status
function cancelMMSCampaign($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
MMS Campaign ID |
$id = 'id';
$result = $mMS->cancelMMSCampaign($id);
Get information about link hits from an MMS Campaign successfully sent
function getMMSCampaignLinkHits(
$id,
$sort = 'last_hit',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
id | Required |
MMS Campaign ID |
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page number of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$id = 'id';
$sort = 'last_hit';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $mMS->getMMSCampaignLinkHits($id, $sort, $filters, $page, $limit);
Get information about an MMS Message
function getMMSMessage($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
MMS ID |
$id = 'id';
$result = $mMS->getMMSMessage($id);
Get information of all MMS Campaigns
function getMMSCampaigns(
$sort = 'updated_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'updated_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $mMS->getMMSCampaigns($sort, $filters, $page, $limit);
Get information about a specific MMS Campaign
function getMMSCampaign($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
Campaign ID |
$id = 'id';
$result = $mMS->getMMSCampaign($id);
Send MMS to single contact
function sendMMS($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
MMS Details |
$body = new MMS();
$result = $mMS->sendMMS($body);
Send an MMS Campaign
function sendMMSCampaign($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
MMS campaign details |
$body = new MMSCampaign();
$result = $mMS->sendMMSCampaign($body);
The singleton instance of the SMSController
class can be accessed from the API Client.
$sMS = $client->getSMS();
Get all the inbound SMS messages (MOs and Replies)
function getSMSInbox(
$sort = 'received_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'received_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $sMS->getSMSInbox($sort, $filters, $page, $limit);
Cancel an SMS Campaign. NOTE: Only campaigns in SCHEDULED or VALIDATING status can be cancelled
function cancelSMSCampaign($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
SMS Campaign ID |
$id = 'id';
$result = $sMS->cancelSMSCampaign($id);
Get SMS Campaign link hits
function getSMSCampaignLinkHits(
$id,
$sort = 'last_hit',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
id | Required |
SMS Campaign ID |
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page number of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$id = 'id';
$sort = 'last_hit';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $sMS->getSMSCampaignLinkHits($id, $sort, $filters, $page, $limit);
Fetch replies to a campaign from recipients
function getSMSCampaignReplies(
$id,
$sort = 'received_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
id | Required |
SMS Campaign ID |
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page number of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$id = 'id';
$sort = 'received_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $sMS->getSMSCampaignReplies($id, $sort, $filters, $page, $limit);
Fetch the activity details report for an SMS campaign already sent. NOTE: The information can be retrieved only for those campaigns that have either been already sent, is in the process of getting sent or for throttled campaigns that is at least partially sent.
function getSMSCampaignReport($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
SMS Campaign ID |
$id = 'id';
$result = $sMS->getSMSCampaignReport($id);
Fetch a list and details of all SMS campaigns in your TransmitMessage account across all statuses
function getSMSCampaigns(
$sort = 'updated_at',
$filters = null,
$page = 0,
$limit = 25)
Parameter | Tags | Description |
---|---|---|
sort | Optional DefaultValue |
Sort by (field name) |
filters | Optional |
Filter by (field value) |
page | Optional DefaultValue |
The page of results to fetch |
limit | Optional DefaultValue |
The number of results to fetch per page; maximum 100 |
$sort = 'updated_at';
$filters = 'filters';
$page = 0;
$limit = 25;
$result = $sMS->getSMSCampaigns($sort, $filters, $page, $limit);
Fetch details of a specific SMS Campaign
function getSMSCampaign($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
SMS Campaign ID |
$id = 'id';
$result = $sMS->getSMSCampaign($id);
Send SMS
function sendSMS($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
SMS details (from, to and content) |
$body = new SMS();
$result = $sMS->sendSMS($body);
Fetch details of an SMS sent
function getSMSRecord($id)
Parameter | Tags | Description |
---|---|---|
id | Required |
Message ID of the SMS |
$id = 'id';
$result = $sMS->getSMSRecord($id);
Send SMS Campaign
function sendSMSCampaign($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
SMS campaign details |
$body = new SMSCampaign();
$result = $sMS->sendSMSCampaign($body);