0

I'm currently trying to figure out a way to create contacts in insightly using a form on my website. I'm using modx and formIt, the form uses formIt to save all the forms, and modx is letting me use the form inputs in the insightly call. I found this online and based my php call off of it.

My PHP call looks like this:

<?php
$modx->log(xPDO::LOG_LEVEL_ERROR,'Insightly CRM Intgration Hook for Contact Form');

$service_url = 'https://api.insight.ly/v2.3/Contacts';
$ch = curl_init($service_url);
curl_setopt($ch,
CURLOPT_HTTPHEADER,
array('Content-Type:application/json',
'Authorization:Basic' .base64_encode('my_api_key')));

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = json_encode(array(
    'CONTACT_ID'=>100,
    'FIRST_NAME'=>"[[+fname]]", 
    'LAST_NAME'=>"[[+lname]]",
    'EMAIL_ADDRESS'=>"[[+email]]",
    'PHONE_MOBILE'=>"[[+phone]]"
    )
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$return = curl_exec($ch);
$err = curl_errno($ch);
$msg = curl_error($ch);

echo $return;

curl_close($ch);
return true;

I am just doing some testing so I just put in an arbitrary CONTACT_ID, I don't know/couldn't find if that needs to be put in specifically or if insightly takes care of it. Leaving it out did not make it work either.

My main goal is to create a contact in the insightly database using insightly v2.3 using an html form.

1 Answers1

0

Well looking at the API reference, they have the contact_id set to 0 - so I would imagine you should try that

insight.ly API Reference

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73