Problem connecting my script through the API to my account


(Customer Service) #1

I’m using a command line php script (from https://developer.infusionsoft.com/resources/helper-libraries/ ) on my machine and I’m trying to figure out the rest api. I did find the long ‘key’ for my “Application/Account” that I normally log into (https://-AppId-.infusionsoft.com) as that is what I want my script to connect to. I just want to write a simple data retrieval script (contacts list for now) to store in a file for analysis later. This script (with more print statements) keeps returning “401 Unathorized” with {“error”:“invalid client”}. My browser can use Infusionsoft “Application/Account” after logging in so how can I get a script (somehow using that API) to retrieve the same info?


(Pav) #2

The Legacy API Key cannot be use for REST API.
You need to register a Developer Account to obtain OAuth Keys.

Visit this page to get started: https://developer.infusionsoft.com/get-started/

If you want to still want to use the Legacy API key, you need to use the XML-RPC API functions instead.

https://developer.infusionsoft.com/docs/xml-rpc/


(Customer Service) #3

I’m trying to use the “Encrypted Key” found on that Admin->Settings->Application page. I hope thats what you mean by Legacy API key.
It looks like I need to send just that code (somewhere…) to get an “authorization code”. Is this the same as an “access token” or “code”(mentioned in the helper SDK)? Then I send this to yet another url (somewhere else…) to get a token back which I can then use to make api calls.
Another issue, I’m trying to enter the “Encrypted Key” on a variety of “Try it” api calls and it just fails. There’s some popup window with an allow button and then it returns to the page without having filled in the token. Do these pages not work?
Can someone please provide sample code? Given that I want to use the Legacy API key(I put this in the clientId field), what do I fill in for the “clientSecret” field? I need this thing to authorize and get the token(not using oauth) and then I can go about using the xmlrpc api.


(Pav) #4

The Encrypted Key is the Legacy API Key.

You will NOT be able to use the Encrypted Key with the Try It calls at all. You need to use the OAuth Access Token to be able to do that.

If you follow the Get Started link, you will need to create a Developer Account, and register an Application to obtain the initial keys.

The PHP SDK Helper Library has sample code in its instructions that show how to authorize your script:

If you still want to use the Encrypted Key, then you can only use these XML-RPC API Functions.
Then you do not have to worry about Client ID, Client Secret, Redirect URLs, Access Tokens and Refresh Tokens.

https://developer.infusionsoft.com/docs/xml-rpc/