| Description: | Specify one or more tags to be added to a contact record. | ||||||||||||||||
| 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
$url = 'https://api.t2connect.com/v1/';
//set POST variables
$data = array(
'account' => [YOUR ACCOUNT URL],
'api_key' => [YOUR API KEY]
'api_action' => 'contact_tag_remove',
'api_output' => 'serialize',
'email' => 'test@example.com', // contact email address (pass this OR the contact ID)
//'id' => 12, // contact ID (pass this OR the contact email address)
'tags' => 'tag1',
// or multiple tags?
//'tags[]' => 'tag1',
//'tags[]' => 'tag2',
);
//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);
$result = unserialize($response);
// JSON decoder
//$result = json_decode($response, true);
// Result info that is always returned
echo 'Result: ' . ( $result['result_code'] ? 'SUCCESS' : 'FAILED' ) . '<br />';
echo 'Message: ' . $result['result_message'] . '<br />';
// 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>';
?>