The code to call API handle subscription
-
Following our previous thread, we would like to add people to different lists based on the user type they select.
This is the code we used:
$array = array(1,2,13);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => site_url()."/wp-json/newsletter/v1/subscribe",
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=".$_POST['tiny_email']."&name=".$_POST['tiny_dispaly_name']."&lists=".$array."",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);With this code, users are added as a wordpress subscriber but not added to a target list.
We want to also add the user to respective lists.
Please advise. Thanks a lot.
Jing
The topic ‘The code to call API handle subscription’ is closed to new replies.