Hi,
Is there any PHP library to use the PHP ISDK functions mentioned in the following API documentation?
https://developer.infusionsoft.com/docs/xml-rpc/
https://tinyurl.com/27pou4jn
Hi @vishal_kumar, the Legacy iSDK does not have OAuth support, you have to add it in yourself.
You just need to change a couple of things to make it work for the Service Account Key.
@Marion_Dorsett2, recently uploaded an updated version of the iSDK with that support.
What version of PHP are you running?
The XML-RPC API functions will carry on running as normal.
@Pav I’m using php 8.2, just found the following link. It is showing the client and secret key code in ISDK. I’m not sure how we can use this ISDK?
I cannot comment on John Borelli iSDK. @John_Borelli use to be a regular contributor in the community, but I have not seen him reply here for a long while.
@Marion_Dorsett2 recently uploaded a modified version of the iSDK with Service Account Key / Personal Access Token support here: Legacy Key Sunsetting - #39 by Marion_Dorsett2
If you still want to use OAuth, then you will have to investigate John iSDK. The Keap PHP SDK, which has official OAuth Support, is completely different to the Legacy iSDK, so you would have to make the necessary code changes to support it.
@Pav Thanks, I’m using this isdk with service account key. It was working but today getting the following error.
PHP Fatal error: Uncaught iSDKException: ERROR: 5 - Didn’t receive 200 OK from remote server thrown in /script/ISDK/isdk.php on line 94
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://api.infusionsoft.com/token
resulted in a 400 Bad Request
response:\n\n {\n “error”: “invalid_request”,\n “error_description”: "Invalid Refresh
Notice: XML-RPC: PhpXmlRpc\Helper\Http::parseResponseHeaders: HTTP error, got response: HTTP/2 429
If you are using a Service Account Key (SAK), then there is no reason to be hitting the /token
endpoint. That is for OAuth 2.0 only.
No, I’m using the xml-rpc, following library with SAK.
https://www.dropbox.com/scl/fi/qgz413b96lsktkx8q0q9b/isdk-PAT-SAK-Compatible.zip?rlkey=hevuym6ea5v07worugiv1f7ly&st=oqaxu9qd&dl=0
XML/RPC is the API being used, PAT/SAK/OAuth is the authentication mechanism.
This is trying to get an OAuth Token for some reason, which you don’t do when using a SAK. We haven’t supported the iSDK for like 10 years, and any updates people made were done on forks. I am not sure what version you are using that supports SAKs. I can’t comment on that, just that it is attempting to get an OAuth token and failing, which is expected if you didn’t put users through an Authorization Flow.
@vishal_kumar That’s the original iSDK that I refactored to support the PAT and SAK keys. It doesn’t support OAuth and it doesn’t use GuzzleHttp. The Guzzle exception error makes me think you’re not using the library you think you’re using.
I tested the refactored code on PHP 7.4 up to PHP 8.2, and I resolved all of the PHP notices, warnings and errors I found in the error_log on my server. I’ve been using it as a drop-in replacement for my client’s and so far no one has reported any errors or issues.
@Marion_Dorsett2 I’m not sure. I have checked the code and did not find the GuzzleHttp used in the code. I have downloaded this ISDK from the dropbox link provided by you.
You can use Postman to create a quick test to the XMLPRC service and test your connection. That would remove your server from the equation and give you a clue about what’s going on with your server.
Setup Postman to send a POST request to the XMLRPC endpoint:
POST https://api.infusionsoft.com/crm/xmlrpc/v1
Pass the custom header:
X-Keap-API-Key: {{KEAP_SAK}}
Pass the body of the request as raw. I used this to add a tag to a contact:
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>ContactService.addToGroup</methodName>
<params>
<param>
<value><string>{{KEAP_SAK}}</string></value>
</param>
<param>
<value><int>CONTACT_ID</int></value>
</param>
<param>
<value><int>TAG_ID</int></value>
</param>
</params>
</methodCall>
If that works, you know you’re connecting properly. If it doesn’t you should be able to work the connection issues out in Postman.
Once you have a working solution in Postman, you can compare the setup on your server, and you should be able to find what’s not communicating properly.
It is working in Postman. I did not get any error.
That’s good news. You know that your key is working.
What I would recommend next is is setting up a test to isolate the iSDK. On the server of your choice I would create a folder, drop the iSDK library into that folder and setup a file to run a single request to load a contact by id.
If that fails, you’re server has changed, and you would need to figure out what that was to resolve it.
If the test passes, then I think of three possible causes:
- You’re accessing the wrong iSDK.
- The iSDK is corrupt and needs to be restored. (did all of the files upload correctly?)
- There’s a conflict with another include.
… what ever you do, just make sure you backup your files before making any changes. From the error you posted, I’m inclined to think you’re pointing to the wrong iSDK.
Thanks, the script is working but sometimes getting the following error.
Error message: Uncaught iSDKException: ERROR: 5 - Didn’t receive 200 OK from remote server (HTTP/2 429 ) in /nas/content/live/ISDK/isdk.php:94
That sounds like you’re making too many requests too quickly and being throttled.
Depending on what’s happening, I would look to see if any of your actions could be passed off to an automation (a.k.a. Camapign), and reduce the number of API calls being made.
If that’s not possible you need to add delays between your API calls.
Take a look at these PHP functions:
- sleep() - Delay execution
- usleep() - Delay execution in microseconds
- time_nanosleep() - Delay for a number of seconds and nanoseconds
Decide which method fits your needs, I prefer usleep() over sleep() and I have not used the time_nanosleep(), but any of those methods will let you delay execution between API requests, and help to avoid throttling.
You may also need to use:
set_time_limit() - Limits the maximum execution time
… depending on how long you have to delay the script execution or your server could timeout the request.
Thanks, It is working but still getting the limit issue. can you provide the working PHP library link to use oAuth2?