Problem with Contact Dupe Check (PHP SDK)


(Jonathan Kaplan) #1

I am trying to integrate my app with Infusionsoft using the PHP SDK. I have been using the sample addWithDupCheck.php as my guide on how to do what I need (because that is basically the functionality I am working on already) but have hit a road block. When I try to do the dupe check using the line

$cid = $infusionsoft->contacts()->where(‘email’, $email)->first();

the entire script stops running with the following Fatal Error

PHP Fatal error: Call to undefined method Infusionsoft\Api\ContactService::where() in /var/www/dan/test_script.php on line 31

I’m stumped, it seems like the error is telling me that “where” can’t be used with contacts even though the sample claims it can be. Am I missing something obvious?


(Bradley Booth) #2

Can you provide a link to the sample, because I am pretty sure where is not a function in the SDK.


(John Borelli) #3

Where is not a function in the sdk. Where is a function in the newer api.


(Bradley Booth) #4

Yeah I just found the example he must be using in the README of the SDK repo.


(Bradley Booth) #5

@Jonathan_Kaplan what version of the SDK are you using?


(John Borelli) #6

@bradb, the link ‘README’ you indicated is not an sdk document?


(Bradley Booth) #7

Not sure what you mean. This is the README in the repo of the Infusionsoft PHP SDK. There where is documented in the examples in it. Under Making Rest Requests


(Jonathan Kaplan) #8

@bradb @John_Borelli Thank you both for your responses. The Readme that was linked is the one that goes with the SDK that I am using. I used composer to install that package on my server. The line in the Readme not the example I was using but I did see where() mentioned in it for tasks so that’s why I started to wonder if contacts just wasn’t set to use it as well.

The piece of code that I am using as a reference for what I want to do is the addWithDupCheck.php file in the samples directory https://github.com/infusionsoft/infusionsoft-php/blob/master/samples/addWithDupCheck.php.

I assumed that samples included with the package would work using that same package, it seems silly to include non-functional samples. Is that not the case?


(John Borelli) #9

Let’s clarify terms. In the Infusionsoft API community the SDK has always referred to the iSDK or the legacy, legacy api that uses the app api key method for authentication. The API is in reference to the current (although termed legacy) api that only uses oauth (this is not the sdk)


(Jonathan Kaplan) #10

@John_Borelli Well that is a bit misleading, especially since the label on the repository is Infusionsoft PHP SDK. But either way, the question still stands, the sample provided in the repository that does what I need throws a fatal error when used. So is it a case where the sample is no longer functional, and if so how do we do the same thing? Or is there something else going on that I am missing by looking at that sample script?


(Michael Fairchild) #11

@Jonathan_Kaplan What version does your composer.json say you have installed for infusionsoft/php-sdk?


(Bradley Booth) #12

We should get together and clarify terms :slight_smile: That is definitely not the same terms we use internally. We just always refer the the php sdk by versions. We referer to the API as the combination of the XML/RPC and REST endpoints on our end. We refer to the SDKs as just layers on top of the APIs to make life easier. Anyhow, maybe we should create a pinned post with terminology.


(John Borelli) #13

Clarification would definitely be good. The sdk has a much different version number than the oauth api version in current use. documentation also provides for separate examples because the sdk is structured completely differently than the current api and looks nothing like the examples for the current api. So in documentation on the right where code examples are available, there is the options for PHP, PHP iSDK, XML-RPC and Python. REST has it’s own interactive docs page. The PHP goes over the oauth version (current). The PHP iSDK goes over the oldest version (using app key). XML-RPC and REST are more obvious. However, and I’m 100 percent certain of this, the documentation has only, within the past week, been changed to show oauth for the sdk as well as it showed the app key use up until then…this is a very recent change but it still remains that the use of the sdk differs from the php api version in current use.

example

to add a contact with the sdk you would instantiate the object and then make the call
$app->addWithDupCheck(array(‘FirstName’ => ‘test’, ‘LastName’ => ‘test’, ‘Email’ => ‘test@test.com’), ‘EmailAndName’);

The current api use looks like this:

$infusionsoft = new \Infusionsoft\Infusionsoft(array(
‘clientId’ => CLIENT_ID,
‘clientSecret’ => CLIENT_SECRET,
‘redirectUri’ => REDIRECT_URL,
));

$infusionsoft->refreshAccessToken();

$infusionsoft->contacts()->addWithDupCheck($data, $dupCheckType)

The point is that there is a clear structural difference (including the absence of ->where in the sdk version)


(Jonathan Kaplan) #14

@MichaelFairchild I used the same line as is listed in the readme, so it is requiring 1.2.*.

As for the terminology, I will let others debate that, although from a general terminology point of view (for general programming, not in regards to specific Infusionsoft usage) the current use of SDK is correct. The API would be the underlying layer while the actual PHP framework would be an SDK.


(Michael Fairchild) #15

Try using 1.3.2-beta instead. Rest ContactService was added in 1.3.


(Jonathan Kaplan) #16

@MichaelFairchild Thank you, that seems to have done the trick. Now when I run the script it returns results like it should. Hopefully this will be the end of my problems and it will go smoothly from here :slight_smile: