Need help for writing php code to send data to the API


New Member
Hello How do you do ?
I'm in trouble with the way i can send data to the api.
i was able to send with the arguments in the url and the api installed on my server works fine.
I use wordpress, and i would like to create an user when he submit to a form.
actualy i'm using "formidable" plugin that have an option "send to an api" and i'm able to send data to mailwizz with the api (so it's running well)

now what want is send data with the wordpress command :
$request = wp_remote_post
(and get rid of the formidable plugin)
what i need is how to write the php code that post my data to the api. (welle i wish it is clear!)

i'm an not pro coder. They say that i need to pub my variables (email, fname, lname) in the $body variable and then send it to the api.
and there i need to write the code that send recive this "post" action and transmit it to the mailwizz software.

here is what i have writen in the api part that recive the "post" from the form.
That works perfectly with the formidable plugin in wordpress .
what i would like to know is how to write the code that send data to this in order to fire it to mailwizz !
(mmmh i wish i make it clear)

// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';
// $endpoint = new MailWizzApi_Endpoint_ListSubscribers();
// sub.php file
require_once dirname(__FILE__) . '/setup.php';
//$listUid = 'kv1692yz71307';// you'll take this from your customers area, in list overview from the address bar.jr414g7s6o288
$listUid = $_POST['LISTUID'];

//$lname = $_GET['lname'];
//$fname = $_GET['fname'];
//$email = isset($_GET['email']) && filter_var($_GET['email'], FILTER_VALIDATE_EMAIL) ? $_GET['email'] : null;
//$lname = isset($_GET['lname']) && filter_var($_GET['lname'];

//$email = $_POST['EMAIL'];
//$//fname = $_POST['FNAME'];
//$lname = $_POST['renom'];

//$codestage = $_POST['LDP_CODE_STAGE'];
$last_code = $_POST['LAST_CODE'];
$codeunique = $_POST['CODEUNIQUE'];
$email = $_POST['EMAIL'];
$fname = $_POST['FNAME'];
$lname = $_POST['LNAME'];
$phone = $_POST['PHONE'];
$statut = $_POST['STATUT'];
$info = $_POST['INFO'];
$url_merci_page = $_POST['URL_MERCI_PAGE'];
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
'EMAIL' => $email,
'LNAME' => $lname,
'FNAME' => $fname,
'PHONE' => $phone,
'STATUT' => $statut,
'INFO' => $info,
'CODEUNIQUE' => $codeunique,
'LAST_CODE' => $last_code,
'URL_MERCI_PAGE' => $url_merci_page


Thanks so much if you can help !
it's inside the "exemple" dir of the API
and it's on the same server where is wordpress (my site) Mailwizz (in a sub dir)
in a phpfile
I don't know, if you're removing formidable from the mix, why not simply point your form to mailwizz's subscribe form and be done with it?
Otherwise, maybe hire a developer to help with this...