rordallas 7 Posted March 9 Report Share Posted March 9 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 <?php 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', 'first_name'=>'firstName', 'last_name'=>'lastName', 'mobile'=>'phone2', 'information'=>'backgroundInfo', ); foreach($attributes as $key=>$value){ if(isset($fieldMap[$key])){ $contact->{$fieldMap[$key]}=$value; // Found in field map, used mapped attribute }else{ $contact->$key=$value; // No match anywhere, assume it's a Contact attribute } } if(isset($_POST['x2_key'])){ $contact->trackingKey=$_POST['x2_key']; } $contact->contactCreate(); // Call API to create contact Header('Location: host.domain/redirect'); // Redirect to homepage Quote Link to post Share on other sites
jack 30 Posted March 13 Report Share Posted March 13 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. -Jack Quote Link to post Share on other sites
rordallas 7 Posted March 14 Author Report Share Posted March 14 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.