Mautic Community Forums

API Connecting Shopping Cart -> Mautic

Hey guys,



I recently decided to create an API to connect my shopping cart service to mautic, so every buyer enters Mautic as a new lead. The shopping cart system sends the data as a POST using CURL, the data is sent to mauticinstalldirectory/api/index.php.



The main problem is how to connect the data sent for the first time from the page into mautic. The problem is the same either using oAuth1a and oAuth2…



So far, we were able to authorize and create a new lead (only if the data predefined inside the API file). Ex:

$lead = $leadApi->create(array(

‘ipAddress’ => $_SERVER,

‘firstname’ => ‘name’,

‘lastname’ => ‘lastname’,

‘email’ => ‘email’,

));



But if i define:



$lead = $leadApi->create(array(

‘ipAddress’ => $_SERVER,

‘firstname’ => $_POST,

‘lastname’ => $_POST,

‘email’ => $_POST,

));



It doesn’t work.



Do you guys have any ideas on how to solve this? Do you need more information?

Hey guys,

I recently decided to create an API to connect my shopping cart service to mautic, so every buyer enters Mautic as a new lead. The shopping cart system sends the data as a POST using CURL, the data is sent to mauticinstalldirectory/api/index.php.

The main problem is how to connect the data sent for the first time from the page into mautic. The problem is the same either using oAuth1a and oAuth2…

So far, we were able to authorize and create a new lead (only if the data predefined inside the API file). Ex:
$lead = $leadApi->create(array(
‘ipAddress’ => $_SERVER[‘REMOTE_ADDR’],
‘firstname’ => ‘name’,
‘lastname’ => ‘lastname’,
‘email’ => ‘email’,
));

But if i define:

$lead = $leadApi->create(array(
‘ipAddress’ => $_SERVER[‘REMOTE_ADDR’],
‘firstname’ => $_POST[‘firstname’],
‘lastname’ => $_POST[‘lastname’],
‘email’ => $_POST[‘email’],
));

It doesn’t work.

Do you guys have any ideas on how to solve this? Do you need more information?

Does it throw any error? Do you have PHP reporting turned on? Try to put these 2 lines at the beginning of your PHP file:

error_reporting(-1); ini_set('display_errors', 'On');