Hey! I’m glad my answer helped.
If you go with basic auth, you can start from here:
<?php
$loginname = 'apiuser';
// Loginname of your API user
$password = 'yourpasswordhere';
// This is the password of the API user
$siteurl = 'yoursiteurl.tld';
// example: mymautic.com
// The data you would like to transfer is called payload. We will set it for now, and later replace with the data we get from the webhook.
$email = 'captain_enterprise-d@starfleet.com';
$firstname = 'Jean-Luc';
$lastname = 'Picard';
$tag = 'purchased';
// This is our curl call:
$curl = curl_init();
// Set some options - we are passing in a user agent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/contacts/new",
CURLOPT_USERAGENT => 'Wesleys Secret App',
CURLOPT_POST => 1,
// posting the payload
CURLOPT_POSTFIELDS => array(
'firstname' => $firstname,
'lastname' => $lastname,
'email' => $email,
'tags' => $tag
)
));
curl_exec($curl);
GL:
Joey