Jump to content
X2Community Forums

Recommended Posts

I am trying to build a web lead capture script using the example code (from the wiki). The Contact is created as advertised except 
for trackingKey. It is never populated. Any guidance would be appreciated.

open-source version 8.5

require 'APIModel.php';
$attributes = $_POST;
$contact = new APIModel('admin','7uoHGRIBlb0lKym56ieiDf3c7idzCCP7','www.host.domain/path/to/x2');
$fieldMap = array( // This map should be of the format 'your_fieldname'=>'x2_fieldname',
foreach($attributes as $key=>$value){
        $contact->{$fieldMap[$key]}=$value; // Found in field map, used mapped attribute
        $contact->$key=$value; // No match anywhere, assume it's a Contact attribute
$contact->contactCreate(); // Call API to create contact
Header('Location: host.domain/redirect'); // Redirect to homepage
Link to post
Share on other sites

Hi Rordalls,
Can you check your api log to make sure it is hitting it correctly. Also I would check to see what fields are required for your contacts and make sure you have them all filled.

Link to post
Share on other sites

Thanks for the reply.

API Log output:

2023/03/14 16:26:03 [trace] [application.api] Checking user record.
2023/03/14 16:26:03 [trace] [application.api] Checking for valid model class.
2023/03/14 16:26:03 [trace] [application.api] Checking user permissions for API transaction.

Email is the only required field and it is being sent. To reiterate, the contact record is perfect except the trackingKey field is empty.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...