Open xemacscode opened 4 years ago
I think you have a syntax error. It should be something like:
$fields = "custom_fields,lead_source_id`;
$contactid = 123456;
$contact = $infusionsoft->contacts()->with($fields)->find($contactid);
so fields are not array? @ajohnson6494
$fields = 'Id', 'Email','AccountId','Username','LastName','FirstName','MiddleName','City', 'Company', 'Country', 'Phone1','PostalCode','State', 'custom_fields';
// $fields = array();
$contact = $infusionsoft->contacts()->with($fields)->find($contactid);
I tried this but it is not working.
It still returns multiple if not all contacts.
Correct, fields is a string value and not an array. So you would want to do something like:
$fields = 'Id,Email,AccountId,Username,LastName,FirstName,MiddleName,City,Company,Country,Phone1,PostalCode,State,custom_fields';
I tried that, but the result still contains multiple contacts. I think the find($contactid);
is being ignored.
The SDK in my opinion is poorly documented. Not all methods in REST documentation is applicable to the SDK and we have to jump back and forth between calling REST methods and XML-RPC methods. I don't know if it is intentional but the documentation isn't clear.
What are you passing into the find function call? because it is only returning one contact for me.
The contact id that I got from webhook.
Will this return custom fields? I have added custom field to the Contact. Will this return the custom field I created or do I have to specify on the optional_parameters
?
If you're just trying to pull up a single contact, you can use the load method instead:
$contact = $infusionsoft->contacts()->load($contactid, $fields);
The rest API doesn't appear to have a field to specify the contactId when you're trying to pull multiple contacts at once unfortunately: https://keys.developer.keap.com/docs/keap-150k/1/routes/contacts/get
Might try it with the email instead to get the hang of the REST api.
If you need to pull more than one contact at once by contactId, you can use the deprecated XMLRPC and its Table Schema like so:
$contactIds = [123,321];
$contacts = $infusionsoft->data()->query('Contact',1000,0,['Id'=>$contactIds],$fields,'Id',true);
$contact = $infusionsoft->contacts()->find($contactid, $fields);
I'm trying to use this to get a full contact details with a certain id. But it is returning all contacts even if I provided the id for a specific contact. How to solve this issue?