Hi there, also facing this problem.
I found in the documentation this Example Request. Sending this via app terminal creates a subscriber with attributes:
curl -u 'username:password' 'https://listmonk.domain/api/subscribers' -H 'Content-Type: application/json' \
--data '{"email":"subsriber@domain.com","name":"The Subscriber","status":"enabled","lists":[1],"attribs":{"city":"Bengaluru","projects":3,"stack":{"languages":["go","python"]}}}'
Now I would like to create a form that fills the $data with according information.
this already works:
<?php
$username='username';
$password='password';
$URL='https://listmonk.domain/api/subscribers';
$data = array(
'email' => 'name@domain.com',
'name' => 'name',
'status' => 'enabled'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result=curl_exec ($ch);
https://listmonk.domain/api/subscribers' = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
curl_close ($ch);
echo $result;
?>
someone has a idea how to build the $data array conforming listmonk specification? I dont get lists and attribs working.
Also it should be possible to trigger listmonk Douple Opt-in e-mail confirmation.