addSMSDeliveries

The addSMSDeliveries function allows you to add new SMS deliveries.

Syntax

writeResult = bApi.addSMSDeliveries(smsDeliveryObject[] deliveries);

Attributes

Name Type Required Description
start dateTime Yes The date the SMS delivery is scheduled to be sent. You can (and should) specify a timezone offset if you do not want the system to assume you are providing a time in UTC (Universal Coordinated Time / Greenwich Mean Time). For the Eastern Time Zone on Daylight Savings Time, this would be YYYY-MM-DDTHH:MM:SS-04:00.
messageId string Yes The id of the SMS message associated with the delivery. You must reference the SMS message you want to use in the SMS delivery by ID. The messageId can be obtained in the application UI. It will appear in the bottom right corner of the screen when viewing an individual SMS message.
recipients deliveryRecipientObject[] No An array of deliveryRecipientObjects that specify the contact(s) and or keyword(s) the SMS delivery will be sent to.
Note: If you are sending to a single contact, use the SMSDeliveryContactsObject to specify the contact ID.
fields smsMessageFieldObject[] Yes If you are using API message tags in your SMS message, you can use the smsMessageFieldObject to specify which content to pass in.

PHP Code Example

<?php 
/* This example will create an SMS delivery and send it to an entire keyword. 
* This example * also demonstrates how to use the fields attribute to pass in data that 
* will replace * API message tags contained in the body of the SMS message. 
* Be sure to replace the placeholder text below with real values. */ 
 
$client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); setlocale(LC_ALL, 'en_US'); 
 
try { 
  $token = "YOUR_TOKEN_HERE";
 
  print "logging in\n";
  $sessionId = $client->login(array('apiToken' => $token))->return;
 
  $session_header = new SoapHeader("http://api.bronto.com/v4",
                   'sessionHeader',
                   array('sessionId' => $sessionId));

  $client->__setSoapHeaders(array($session_header));
 
   $client->setSoapHeaders(array($session_header)); // Make delivery start timestamp 
   $now = date('c'); // Used to replace API message tags in your SMS message with the // value you pass in for 'content'.
 
   $smsMessageFieldObject = array('name' => 'SOME API MESSAGE TAG NAME', 'content' => 'SOME EXAMPLE CONTENT'); 
   $delivery = array('start' => $now, 'messageId' => 'ADD SMS MESSAGE ID HERE', 'keywords' => 'ADD KEYWORD ID HERE', 'fields' => $smsMessageFieldObject ); 

   $write_result = $client->addSMSDeliveries(array($delivery)
   )->return;



 
   if ($write_result->$errors) {
     print "There was a problem adding the SMS delivery:\n"; 
     print_r($write_result->results);
    } 
   else { 
     print "The SMS delivery has been successfully created.\n"; } 
   } 
     catch (Exception $e) { 
       print "uncaught exception\n";
       print_r($e);
     } 

Python Code Example

import sys
import logging
from suds.client import Client
from suds import WebFault
from datetime import datetime
 
 
# This example script will login to the API, and schedule an 
# SMS delivery. This example demonstrates how to send to a specific 
# contact. It also demonstrates how to 
# pass in content to replace API message tags contained in the SMS message.
 
# BE SURE TO REPLACE ALL PLACEHOLDER TEXT
 
# Tested with Python 2.6.1 and suds soap library version 0.4
 
# See suds home page:
# https://fedorahosted.org/suds/
 
 
# Bronto API WSDL
BRONTO_WSDL = 'https://api.bronto.com/v4?wsdl'
 
# Start up basic logging
logging.basicConfig()
 
# Replace the placeholder text with a valid
# API token
TOKEN = "ADD API TOKEN HERE"
 
 
# Login using the token to obtain a session ID
bApi = Client( BRONTO_WSDL )
 
try:
    session_id = bApi.service.login(TOKEN)
# Just exit if something goes wrong
except WebFault, e:
   print '\nERROR MESSAGE:'
   print e
   sys.exit()
 
# Set up the soap headers using the
# session_id obtained from login()
session_header = bApi.factory.create("sessionHeader")
session_header.sessionId = session_id
bApi.set_options(soapheaders=session_header)
 
# Get the current date and time so we can send the
# SMS message now
sendtime = datetime.now()
 
# Set up the smsdeliveryObject
# Be sure to replace the placeholder text below
add_sms_delivery = bApi.factory.create('smsdeliveryObject')
add_sms_delivery.start = sendtime
add_sms_delivery.messageId = 'SMS MESSAGE ID'
 
 
# Set up the deliveryRecipientObject object. This allows you
# to send to specific contacts and or keywords. Multiple
# contacts can be sent to by passing in an array of contactIds.
deliveryRecipientObject = bApi.factory.create('deliveryRecipientObject')
deliveryRecipientObject.type = 'contact'
deliveryRecipientObject.id = 'CONTACT ID'
add_sms_delivery.recipients = deliveryRecipientObject
 
# set up the smsMessageFieldObject. This allows you to pass
# in content that will replace API message tags in the SMS
# message.
smsMessageFieldObject = bApi.factory.create('smsMessageFieldObject')
smsMessageFieldObject.name = 'API MESSAGE TAG NAME'
smsMessageFieldObject.content = 'SOME CONTENT TO PASS IN'
add_sms_delivery.fields = smsMessageFieldObject
 
try:
    delivery = bApi.service.addSMSDeliveries(add_sms_delivery)
    if delivery.results[0].isError == True:
        print 'There was an error with your request:'
        print delivery.results[0]
        sys.exit()
    else:
        print 'The SMS delivery has been sent.'
except WebFault, e:
    print '\nERROR MESSAGE:'
    print e
    sys.exit()