How can I link contacts via the PHP ISDK?


(Sehar Sohail) #1

I see that there’s a link to this fucntionality in the docs, but the documentation there itself is blank:
https://developer.infusionsoft.com/docs/xml-rpc/#contact-link-contacts

Any help would be appreciated.


Is there a way to link contacts using the REST API?
(John Borelli) #2

interesting. no code for either php versions, just xml and python. Since it appears to be a part of the xml-rpc maybe you can get away with calling:

$this->methodCaller(“ContactService.linkContacts”, $carray); ?.. maybe?


Link Contacts PHP iSDK example
(Sehar Sohail) #3

Hi John,
Thanks, I’ll try that and let everyone know how that goes.


(Sehar Sohail) #4

I actually wrote this into the isdk.php:

public function linkContacts($contactId1, $contactId2, $contactLinkTypeId){
    $carray = array(
         php_xmlrpc_encode((int) $contactId1),
         php_xmlrpc_encode((int) $contactId2),
         php_xmlrpc_encode((int) $contactLinkTypeId)
    );
    return $this->methodCaller("ContactService.linkContacts", $carray);
}

worked like a charm!


(John Borelli) #5

@Sehar_Sohail,

That is awesome! Thanks for sharing this so that others can benefit from the effort. Excellent!


(Sehar Sohail) #6

No problem!
Relatedly, I wrote this too – If you need to list all linked contacts for an account:

public function listLinkedContacts($contactId){
$carray = array(
php_xmlrpc_encode((int) $contactId)
);
return $this->methodCaller(“ContactService.listLinkedContacts”, $carray);
}


(John Borelli) #7

Perfect! I was actually looking at this same thing the other day :wink:

Thanks again!