Add new mailing list.
| Description: | Add a new mailing list, just like you would on the Manage Lists page of the admin section. | ||||||||||||||||||||||||||||||||||||||||||||
| HTTP method: | POST |
||||||||||||||||||||||||||||||||||||||||||||
| Supported output formats: | xml, json, serialize |
||||||||||||||||||||||||||||||||||||||||||||
| Requires authentication: | true |
||||||||||||||||||||||||||||||||||||||||||||
| Parameters: |
* indicates requirement. Underlined params include in URL, otherwise as part of the post body. POST data must be formatted as
Content-Type: application/x-www-form-urlencoded. We don't accept any other input formats like JSON.
|
||||||||||||||||||||||||||||||||||||||||||||
| Example response: |
|
PHP Example
This is an example of using the contact_sync call with PHP. You can replicate the same idea in virtually any other programming language. The example shown is using serialize as the output format. You can change that to XML or JSON if you would like.
<?php
// By default, this sample code is designed to get the result
$url = 'https://api.t2connect.com/v1/';
// here we define the data we are posting in order to perform an update
$data = array(
'account' => 'YOUR_URL',
// replace this with your API Key
'api_key' => 'YOUR_API_KEY',
// this is the action that adds a contact
// this is the action that fetches a list info based on the ID you provide
'api_action' => 'list_add',
'id' => 0, // adds a new one
'name' => ' ', // list name
'subscription_notify' => '', // comma-separated list of email addresses to notify on new subscriptions to this list
'unsubscription_notify' => '', // comma-separated list of email addresses to notify on any unsubscriptions from this list
'to_name' => "Recipient", // if contact doesn't enter a name, use this
'carboncopy' => '', // comma-separated list of email addresses to send a copy of all mailings to upon send
//'p_use_captcha' => 1, // uncomment to require CAPTCHA ("enter text on image" field) for this list
//'get_unsubscribe_reason' => 1, // uncomment to ask for reason when unsubscribing
//'send_last_broadcast' => 1, // uncomment to send the last broadcast campaign when subscribing
//'require_name' => 1, // uncomment to require name with email when subscribing
// Sender information (all fields below) required
'sender_name' => '', // Company (or Organization)
'sender_addr1' => '', // Address
'sender_zip' => '', // Zip or Postal Code
'sender_city' => '', // City
'sender_country' => '', // Country
'sender_url' => '', // URL
'sender_reminder' => 'You subscribed on our web site', // Sender's reminder to contacts
);
//open connection
$ch = curl_init($url);
$json_data = json_encode($data);
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment if you get no gateway response and are using HTTPS
$response = (string)curl_exec($ch); // execute curl post and store results in $response
if ( !$response ) {
die('Nothing was returned. Do you have a connection to Email Marketing server?');
}
//close connection
curl_close($ch);
// unserializer
$result = unserialize($response);
// JSON decoder
//$result = json_decode($response, true);
// The entire result printed out
echo 'The entire result printed out:<br />';
echo '<pre>';
print_r($result);
echo '</pre>';
// Raw response printed out
echo 'Raw response printed out:<br />';
echo '<pre>';
print_r($response);
echo '</pre>';
?>