0

I am using a PHP library (https://github.com/Insightly/insightly-php) with great success for the Insightly API. More information on the Insightly API can be found here: https://api.insight.ly/v2.2/Help

My goal is to have an organisation and a contact added to Insightly on a form submission and to then link the two together. I can add the organisation and the contact without any issues but I am having troubles linking the two afterwards. When I add in the code to link the two it is only adding the organisation and not the contact.

Please view my code below:

$organization = $i->addOrganization($newOrganization);
$getOrganizationID = $i->getOrganization($company);

$id = json_decode($getOrganizationID, true);

$newContact = (object)array(
"FIRST_NAME" => $first_name,
"LAST_NAME" => $last_name,
"CONTACTINFOS" => array(
(object)array(
"TYPE" => "EMAIL",
"LABEL" => "WORK",
"DETAIL" => $email,
),
(object)array(
"TYPE" => "PHONE",
"LABEL" => "WORK",
"DETAIL" => $phone,
)
),
"LINKS" => array(
(object)array(
"ORGANISATION_ID" => $id[0]['ORGANISATION_ID'],
)
),
);

$contact = $i->addContact($newContact);
Grokify
  • 15,092
  • 6
  • 60
  • 81
Bryan
  • 35
  • 4
  • The following line of code seems to be breaking my code: ' $getOrganizationID = $i->getOrganization($company);' The function that is being called is as follows: 'public function getOrganization($id){ return $this->GET("/v2.1/Organisations/$id")->asJSON(); }' Hopefully this helps. – Bryan Feb 19 '16 at 17:29

1 Answers1

0

I had a faulty link in the getOrganization() function and have since fixed it.

Bryan
  • 35
  • 4