try {
// Set the REST API URL
$restURL = "https://api.enginemailer.com/restapi/subscriber/emsubscriber/updateSubscribers";
// Initiate the cURL Method with the REST API URL Specified Previously.
$client = curl_init($restURL);
// Custom Fields declarations
$jsonCustomFields1->customfield_key = "customfield_key";
$jsonCustomFields1->customfield_value = "customfield_value";
$jsonCustomFields2->customfield_key = "customfield_key";
$jsonCustomFields2->customfield_value = "customfield_value";
// Create the JSON Object with the Email, Subcategories, and Custom Fields
// Email
$jsonObject->email = "Email To Update";
// Add the ID of the Subcategories into an Array to assign this Subscribers into the Subcategories
$jsonObject->subcategories = array();
// Custom Fields
$jsonObject->customfields = array($jsonCustomFields1, $jsonCustomFields2);
// Encode the Json Object into a String
$jsonEncoded = json_encode($jsonObject);
// Add APIKey into the Headers to be passed in.
$headers = array(
"APIKey : "
);
// Return the Transfer as String
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
// Use POST Method
curl_setopt($client, CURLOPT_POST, true);
// Add Headers for Request
curl_setopt($client, CURLOPT_HTTPHEADER, $headers);
// The Post Parameters that we will be Passing
curl_setopt($client, CURLOPT_POSTFIELDS, $jsonEncoded);
// Calls the Rest API
$curl_response = curl_exec($client);
curl_close($client);
var_dump($curl_response);
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}