PHP Docs for REST


(Owen Lees) #1

Hi.
After reading and experimenting (with quite a degree of frustration sadly) I have been able to get past the initial auth sequence and am now playing (trying to) with the PHP API which I have installed via composer.

Are there any docs for this helper class? I’m using an editor which shows me the class methods etc, but when for instance I do a call to ->contacts() I get a RECURSION error in the response.

This is clearly me not understanding which call to use, so can anyone point me at some docs which deal with the php sdk please?


(Owen Lees) #2

Aaah… I may have answered my own question.
Does the php sdk from GitHub only deal with the xml-rpc and not REST?


(John Borelli) #3

So this is kind of a yes an no answer. RPC is an endpoint structure that separates function by url/directory structure. REST is a state based method using one url for each object (generally) so …/contact might be a REST endpoint. The method or state that you use determines the function. So to get a list of contacts you might send a GET request to the …/contact endpoint. In RPC the endpoint to get a list might be more like …/contact/v1/list/get which ends with the function in question. So support files are not needed for REST as any post, put, get etc method can be used to the same endpoint via standard HTTP protocols like cURL. So the xml-rpc files (from github) don’t contain support files for REST ‘per se’ except for webhook registration and oauth authentication but they do contain the Infusionsoft object that is a container for all the other objects (contact, group/tag etc) which handles the rpc calls for you.


(Michael Fairchild) #4

The Rest services in the PHP SDK are based Laravel’s Eloquent model. The Readme in the sdk has some basic examples of how to use it. https://github.com/infusionsoft/infusionsoft-php#making-rest-requests

Take a look at those docs in the readme and let me know if that doesn’t get you going.


(Owen Lees) #5

Hi and thanks for the answer, I was reading the release notes for the SDK which implied that the REST endpoints were as you say - and the class would load the REST side of things first unless explicitly told not to (so far so good).

I wonder if I have an old version of the SDK now, as the methods for task (for instance) do not contain the all() method which is noted within the Github docs.

I also can see the contacts() endpoint - but on using it I get an RECURSION error in the body returned.

I do not get this recursion error if I simply use Guzzle separately and make a REST GET request to /contacts.


(Owen Lees) #6

Hi Michael
I have indeed looked at the docs and interrogated the source code of the SDK acquired via composer - which appears to be at odds with the docs, I wonder if you could identify which version is in fact the latest version of the SDK?


(Owen Lees) #7

I downloaded the DEV Beta version 5, am now downloading 1.3…


(Owen Lees) #8

The return now is not RECURSION but rather nothing (at least it returns an object, but nothing in the object that would be considered useful.

So… can you think why the Guzzle request to the API “/contacts” would return correctly and the same request to “$infusionsoft->contacts()” (using sdk 1.3) returns differently?

When i do the Guzzle version i get a list of contacts back (correctly) - with the sdk i get this:

object(Infusionsoft\Api\Rest\ContactService)#38 (11) {
[“full_url”] => string(49) “https://api.infusionsoft.com/crm/rest/v1/contacts
[“updateVerb”:protected] => string(5) “patch”
[“return_key”] => string(8) “contacts”
[“client”:protected] => object(Infusionsoft\Infusionsoft)#19 (13) {
[“url”:protected] => string(42) “https://api.infusionsoft.com/crm/xmlrpc/v1
[“auth”:protected] => string(51) “https://signin.infusionsoft.com/app/oauth/authorize
[“tokenUri”:protected] => string(34) “https://api.infusionsoft.com/token
[“clientId”:protected] => string(24) “"
[“clientSecret”:protected] => string(10) ""
[“redirectUri”:protected] => string(48) "
"
[“apis”:protected] => array(0) {
}
[“debug”:protected] => bool(true)
[“httpClient”:protected] => NULL
[“httpLogAdapter”:protected] => NULL
[“serializer”:protected] => NULL
[“needsEmptyKey”] => bool(true)
[“token”:protected] => object(Infusionsoft\Token)#18 (4) {
[“accessToken”] => string(24) "
"
[“refreshToken”] => string(24) "
**”
[“endOfLife”] => int(1502560005)
[“extraInfo”] => array(2) {
[“token_type”] => string(6) “bearer”
[“scope”] => string(27) “full|****.infusionsoft.com”
}
}
}
[“where”:protected] => array(0) {
}
[“optionalProperities”:protected] => array(0) {
}
[“attributes”:protected] => array(0) {
}
[“hidden”:protected] => array(0) {
}
[“visible”:protected] => array(0) {
}
[“appends”:protected] => array(0) {
}
[“casts”:protected] => array(0) {
}
}


(Owen Lees) #9

The download and further forays into the code fixed this for me - using all().

Thanks for the pointers.