Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$infusionsoft->contacts()->find($contactid, $fields); returns all contacts #253

Open
xemacscode opened this issue Apr 24, 2020 · 10 comments

Comments

@xemacscode
Copy link

$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?

@ajohnson6494
Copy link
Contributor

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);

@xemacscode
Copy link
Author

so fields are not array? @ajohnson6494

@xemacscode
Copy link
Author

xemacscode commented Apr 24, 2020

$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.

@xemacscode
Copy link
Author

It still returns multiple if not all contacts.

@ajohnson6494
Copy link
Contributor

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';

@xemacscode
Copy link
Author

I tried that, but the result still contains multiple contacts. I think the find($contactid); is being ignored.

@xemacscode
Copy link
Author

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.

@ajohnson6494
Copy link
Contributor

What are you passing into the find function call? because it is only returning one contact for me.

@xemacscode
Copy link
Author

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?

@Ultimater
Copy link
Contributor

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants