I was wondering how I could merge the variables at the top of my PHP file with the dict in my cURL POST method.
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
curl_setopt_array($curl, array(
CURLOPT_URL => "CUSTOM_URL",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"email_address\": \"thisperson@gmail.com\", \"status\": \"subscribed\", \"merge_fields\": {\"FNAME\": \"Bob\", \"LNAME\": \"Dylan\"}}",
CURLOPT_HTTPHEADER => array(
"authorization: Basic UN:PW",
"cache-control: no-cache",
"content-type: application/json",
),
));
So essentially, how do I put First Name, Last Name, Email, etc into "{\"email_address\": \"thisperson@gmail.com\", \"status\": \"subscribed\", \"merge_fields\": {\"FNAME\": \"Bob\", \"LNAME\": \"Dylan\"}}"
(to replace thisperson@gmail.com
, Bob
, etc.)