Sending a SMS campaign

smsCampaigns()

SMS campaign list is returned by request. When sending a request, it is possible to perform data selection due to which SMS campaigns will be returned from the database. Selection parameters are transferred, while SMS campaign list (array) is returned. If selection parameters are not transferred, information about all SMS campaigns is returned.

smsCampaigns(array $filters, integer $start, integer $limit) : array
Input parameters
  • filters - selection parameters (optional). Array consisting of any of following parameters:
    • campaign_id - SMS campaign ID (optional)
    • recipients - list ID (optional)
    • status - status of SMS campaign (sent, draft, sending) (optional)
    • sender - SMS sender name (optional)
    • title - name of SMS campaign (optional)
    • sendtime_start - sending time before (SMS campaigns sent before a specific date are selected) (optional)
    • sendtime_end - sending time after (SMS campaigns sent after a specific date are selected) (optional)
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page(optional). Default value is 25. Maximum allowable value is 1000.

Information obtained

Array of SMS campaigns. Each SMS campaign is represented as an array that includes:

  • id - SMS campaign ID used in other API functions
  • web_id - SMS campaign ID for web version (used for URL link from archive)
  • title - name of SMS campaign
  • create_time - date of creating SMS campaign
  • send_time - date of sending SMS campaign
  • sms_sent - number of sent SMS
  • status - status of SMS campaign (sent, draft, paused, sending)
  • sender - SMS sender name
  • analytics - whether Google Analytics tool is integrated (true, false)
  • analytcs_tag - name of Google Analytics campaign
  • track_clicks - whether clicks are counted (true, false)
  • unicode - whether to send out the SMS campaign using unicode text option is set (true, false)
  • concatenate - whether to send out multiple SMS messages option is set (true, false)

Examples

mgapi_smsCampaigns.php
smsCampaigns();
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaigns()!";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo sizeof($retval)." SMS Campaigns Returned:\n";
    foreach($retval as $c){
        echo "Campaign Id: ".$c['id']." - ".$c['title']."\n";
        echo "\tStatus: ".$c['status']."\n";
        echo "\tsent: ".$c['send_time']." to ".$c['sms_sent']." members\n";
    }
}

smsCampaignCreate()

New SMS campaign is created and array of parameters is passed including information about SMS campaign settings and SMS message content.

smsCampaignCreate(array $options, array $content) : string
Input parameters
  • options - SMS campaign settings. Array consisting of:
  • sender - SMS sender name. Specify a name from which the campaign will be received (see Registering SMS sender name)
    • recipients - options for specifying recipients. Array consisting of:
      • list_id - list ID
      • segment_id - segment ID (optional). User created segment based only on given list ID
      • merge - name of the SMS field. For example MERGE10, SMS
    • tracking - SMS campaign tracking (optional). Array of boolean values for following options:
      • clicks - click tracking (default value is true)
    • title - name of the campaign (optional)
    • analytics - web analytics integration option (optional). Array of options for given web analytics tool. 
      For example, to use Google Analytics, this option should look like: array( "google" => "YOUR_GOOGLE_ANALYTICS_KEY" ) "YOUR_GOOGLE_ANALYTICS_KEY" then will be added to all of the links found in your email. Statistics will be accessible in your Google Analytics account.
    • unicode - whether to send out the SMS campaign using unicode text (optional). If set to true, SMS will be sent with mitigation and longitude marks. This is useful for foreign languages and special characters. Default value is false.
    • concatenate - whether to send out multiple SMS messages if the text is too long (optional). Send SMS campaign up to 3 joint SMS. Default value is false.
  • content - campaign email content. Array consisting of:
    • text - SMS message OR
    • template_id - user defined SMS template ID to be used for generating SMS message
Information obtained
  • ID of the new SMS campaign

Examples

mgapi_smsCampaignCreate.php
 $smsSenderID,
    'recipients' => array(
        'list_id' => $listId,
        //'segment_id' => $segmentId,
        'merge' => $smsMergeField,
    ),
    'tracking' => array(
        'clicks' => true
    ),
    'analytics' => array(
        'google' => 'my_google_analytics_key'
    ),
    'title' => 'Test SMS Title',
    'unicode' => true,
    'concatenate' => true
);
/*
$content = array(
    'template_id' => 'template_id',
);
*/
$content = array(
    'text' => 'some pretty content message',
);
 
$retval = $api->smsCampaignCreate($options, $content);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignCreate()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "New SMS Campaign ID:".$retval."\n";
}

smsCampaignSendNow()

Submit request of delivering SMS campaign that previously was saved as a draft. SMS campaign is sent immediately. SMS campaign ID number is passed as a parameter.

smsCampaignSendNow(string $cid) : boolean
Input parameters
  • cid - SMS campaign ID
Information obtained
  • true, if request of SMS campaign delivery has succeeded. Otherwise, an error message is returned.

Examples

mgapi_smsCampaignSendNow.php
smsCampaignSendNow($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load smsCampaignSendNow()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "SMS Campaign Sent!\n";
}

smsCampaignUpdate()

Update of one of the previously created values of SMS campaign parameters.

Works if SMS campaign is not yet sent.
smsCampaignUpdate(string $cid, string $name, mixed $value) : boolean
Input parameters
  • cid - SMS campaign ID
  • name - name of parameter, such as sender, recipients, title etc. (see Creation of new SMS campaign possible parameter names). Additional parameter content is provided, to update message content.
  • value - value of parameter (see Creation of new SMS campaign possible parameter values)
    If list ID is used, all of the previous lists will be deleted.
    If template ID is used, SMS message content will be overwritten by content of the given template.
Information obtained
  • true, if parameter update has succeeded. Otherwise, an error message is returned.

Examples

mgapi_smsCampaignUpdate.php
smsCampaignUpdate($cid, $name, $value);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignUpdate()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "SUCCESS! \n";
}

smsCampaignSchedule()

SMS campaign delivery is scheduled. Time is set according GMT, but if a specific time zone needs to be set up, required number of hours have to be added or subtracted. Time is written in YYYY-MM-DD HH:II:SS +GMT format. Example of time format: ‘2020-05-18 11:59:21 +0100’, where ‘+0100’ is an added hour to the standard time.

smsCampaignSchedule(string $cid, string $schedule_time) : boolean
Input parameters
  • cid - SMS campaign ID
  • schedule_time - sending time (according to GMT)
Information obtained
  • true, if scheduling has succeeded. Otherwise, an error message is returned.

Examples

mgapi_smsCampaignSchedule.php
smsCampaignSchedule($cid, $schedule_time);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load smsCampaignSchedule()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "SMS Campaign Scheduled to be delivered $schedule_time!\n";
}

smsCampaignUnschedule()

SMS campaign delivery time is unscheduled. SMS campaign is saved as a draft and is not delivered.

smsCampaignUnschedule(string $cid) : boolean
Input parameters
  • cid - SMS campaign ID
Information obtained
  • true, if unscheduling has succeeded. Otherwise, an error message is returned.

Examples

mgapi_smsCampaignUnschedule.php
smsCampaignUnschedule($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load smsCampaignUnschedule()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "SMS Campaign Unscheduled!\n";
}

smsCampaignReplicate()

Existing SMS campaign is replicated and the ID of the new SMS campaign is returned.

smsCampaignReplicate(string $cid) : string
Input parameters
  • cid - SMS campaign ID
Information obtained
  • SMS campaign copy ID

Examples

mgapi_smsCampaignReplicate.php
smsCampaignReplicate($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignReplicate()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "New SMS Campaign Id = ".$retval."\n";
}

smsCampaignTemplates()

Submit request and as a result obtain a list (array) with saved SMS templates in user’s account.

smsCampaignTemplates() : string
Information obtained

Array of SMS templates. Each SMS template is represented as an array that includes:

  • id - template ID
  •  text - template text

Examples

mgapi_smsCampaignTemplates.php
smsCampaignTemplates();
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load smsCampaignTemplates()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Your templates:\n";
    foreach ($retval as $tmpl) {
        echo "\t" . $tmpl['id'] . " - " . $tmpl['name'] . " - " . $tmpl['layout'] . "\n";
    }
}

smsCampaignDelete()

Delete SMS campaign from the account of a specific Mailigen user.

It is not possible to restore the deleted SMS campaign (!). By deleting SMS campaign, SMS campaign reports will also be deleted.
smsCampaignDelete(string $cid) : boolean
Input parameters
  • cid - SMS campaign ID
Information obtained
  • true, if the request for SMS campaign delete has succeeded. Otherwise, an error message is returned.

Examples

mgapi_smsCampaignDelete.php
smsCampaignDelete($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignDelete()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "SMS Campaign Deleted!\n";
}

smsSenderIdRegister()

Send request for registering SMS sender information. Upon receipt of an SMS, customers will see the sender's name. New Sender ID is registered within 1 business day.

smsSenderIdRegister(string $sender, string $phone, string $company, string $fullname, string $companyposition, string $comments) : boolean
Input parameters
  • sender - desired SMS Sender ID or name
  • phone - alternate mobile phone number
  • company - company name
  • fullname - contact person full name
  • companyposition - company position
  • comments - additional comments
Information obtained
  • true, if the request has been accepted. Otherwise, an error message is returned.

Examples

mgapi_smsSenderIdRegister.php
smsSenderIdRegister($sender, $phone, $company, $fullname, $companyposition, $comments);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsSenderIdRegister()!\n";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "The request has been received!\n";
}

© 2010-2017 Mailigen. All rights reserved.