public function register_contact($email, $first_name, $country, $zip) { // Initialize a cURL object $payload = json_encode(array( "email_address" => array("address" => $email, "permission_to_send" => "implicit"), "first_name" => $first_name, "create_source" => "Account" )); // Define base URL $base = 'https://api.cc.email/v3/contacts'; // Create full request URL with chosen parameters $url = $base; // Set the URL $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); // Set authorization header $authorization = 'Authorization: Bearer ' . get_option('constant_token'); curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); // Make the call $result = curl_exec($ch); // Close cURL curl_close($ch); echo $result; }
... View more