Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run an example #21

Open
sr9yar opened this issue Dec 24, 2018 · 1 comment
Open

Unable to run an example #21

sr9yar opened this issue Dec 24, 2018 · 1 comment

Comments

@sr9yar
Copy link

sr9yar commented Dec 24, 2018

I've copy-pasted an example from here https://github.com/infusionsoft/Official-API-Python-Library/blob/master/example.py

from infusionsoft.library import Infusionsoft

infusionsoft = Infusionsoft( 'APPNAME',  'APIKEY' )

# Example 1: Add Contact
#----------------------------------------------------------------------------------------
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '[email protected]'}
print(infusionsoft.ContactService('add', contact))

Got app name and the key from here:
https://keys.developer.infusionsoft.com

Credentials
Application APPNAME
client_id APIKEY 
client_secret serret23sdffd 
Status: active 
Created: 2 hours ago

When I run the code I get an error:

Traceback (most recent call last):
  File "inf.py", line 8, in <module>
    print(infusionsoft.ContactService('add', contact))
  File "/root/miniconda/lib/python3.6/site-packages/infusionsoft/library.py", line 21, in function
    return call(self.key, *args)
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1279, in send_request
    self.send_content(connection, request_body)
  File "/root/miniconda/lib/python3.6/xmlrpc/client.py", line 1309, in send_content
    connection.endheaders(request_body)
  File "/root/miniconda/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/root/miniconda/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/root/miniconda/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/root/miniconda/lib/python3.6/http/client.py", line 1392, in connect
    super().connect()
  File "/root/miniconda/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/root/miniconda/lib/python3.6/socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/root/miniconda/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

@smarcotte4g
Copy link

The Infusionsoft class is using the Legacy API Key. To find it in Max Classic, in the Top Nav Click Profile -> Api Settings -> Legacy API Key.

from infusionsoft.library import Infusionsoft
app_name = ''
api_key = ''
infusionsoft = Infusionsoft(app_name, api_key)
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '[email protected]'}
print(infusionsoft.ContactService('add', contact))

If you want to use your https://keys.developer.keap.com/ then you would use InfusionsoftOAuth. This will require you to authenticate to the application and receive an Access Token which expires every 24 hours. https://developer.infusionsoft.com/docs/rest/#section/Authentication

from infusionsoft.library import InfusionsoftOAuth
access_token = ''
infusionsoft = InfusionsoftOAuth(access_token)
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '[email protected]'}
print(infusionsoft.ContactService('add', contact))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants