PHP SDK - REST API - Find contact by email? Check for Duplicate?

I’m using the PHP SDK, using the REST API, and I can’t figure out how to do the following:

  • Find a contact by email
  • Prevent a duplicate created contact by email

As for finding a contact by email, I’ve tried all of the following:

$infusionsoft->contacts()->findByEmail('email@email.com');  // Method not found for REST
$infusionsoft->contacts()->find(array('email' => 'email@email.com');  // Complains that first parameter needs to be a string
$infusionsoft->contacts()->where(array('email' => 'email@email.com')->find(); // Doesn't work

I just can’t figure out how to do it…

As for trying to create a contact and avoid duplicates, here’s how I’m creating the contact, which works fine, but will create duplicates:

$infusionsoft->contacts()->create($contact);

I’ve tried adding in the following to my $contact array, but it errors out with this call:

"duplicate_option" => "Email"

Any help would be greatly appreciated.

Hi @Jer_Fortenberry adding a contact with dup check was recently added in the sdk for REST. You should now be able to use

$infusionsoft->contacts()->create($data,true);

See the update to ContactService.php for more information

@Carlos_Ochoa - Ahh, so this is brand new to the SDK for REST then - just added?

Can you please update everything so that composer will download all the latest code?

@MichaelFairchild I think updated all this already?

It has been added to the SDK but hasn’t been tagged in a release yet so it’s only available directly in the master branch.

1 Like

Has anyone managed to fathom the first part of this question though:

As for finding a contact by email, I’ve tried all of the following:

$infusionsoft->contacts()->findByEmail('email@email.com');  // Method not found for REST
$infusionsoft->contacts()->find(array('email' => 'email@email.com');  // Complains that first parameter needs to be a string
$infusionsoft->contacts()->where(array('email' => 'email@email.com')->find();

Because like the OP - I can't find out how to search by email on a contact using the PHP SDK.
Documentation seems to be scarce.

Thanks in advance,

I’m in the exact same situation. Trying to migrate an old code base using the XML-RPC API to the new REST one, but my application’s workflow all starts with finding a contact by email, first or last name.
This is mind-boggling.