How to SET a contact into a list from PHP

We are working on a WordPress tool, we will be asking for the user’s email and then we are trying to create a contact and then we want to add him to a list (list ID 3), however, we are only able to retrieve the full list of contacts, we are using the following code.

$key = KEY;
$url = URL;

$request = array(
‘method’ => ‘GET’,
‘user-agent’ => ‘WordPress/’ . $wp_version . '; ’ . home_url(),
‘headers’ => array(
‘content-type’ => ‘application/json’,
‘Api-Token’ => $key,
)
);

$response = wp_remote_post($url, $request);

return print_r($response);

We know we have to do a SET request in a similar way, according to the documentation in order to create a user and then add it into a list we would have to create two JSON files, Overview Overview, we only see examples of the JSON files but we don’t understand how can we pass that JSON into that request, do you guys have any full example of PHP of how this should work?

Thanks in advance

I’m not familiar with using PHP, but maybe this example can help you understand how to post JSON to the ActiveCampaign API. I think Wordpress may have a built-in function for doing a POST instead of using curl.

I hope this helps!