Last active
August 24, 2016 20:25
-
-
Save ninapavlich/4a95778226a0377620ed474125a3fd7e to your computer and use it in GitHub Desktop.
Convio CRM API Integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import xml.etree.ElementTree | |
""" | |
Integrate with the Convio / Blackbaud / Luminate CRM API | |
""" | |
def add_crm_user(first_name, last_name, email_address, email_opt_in, city, state, country): | |
API_KEY = "" #See Setup -> Site Options -> Open API Configuration | |
API_USERNAME = "" | |
API_PASWORD = "" | |
API_SURVEY_ID = "" #This is the survey ID that collects the data | |
#STEP 1: Generate SSO Auth Token: | |
url = 'https://secure3.convio.net/stpc/site/CRConsAPI' | |
data = { | |
'v' : '1.0', | |
'method': 'login', | |
'api_key' : API_KEY, | |
'user_name' : API_USERNAME, | |
'password' : API_PASWORD | |
} | |
r = requests.post(url, data = data) | |
print r.text | |
root = xml.etree.ElementTree.fromstring(r.text) | |
token = None | |
for child in root: | |
if 'token' in child.tag: | |
token = child.text | |
#STEP 2: Submit info to Survey endpoing | |
url = 'https://secure3.convio.net/stpc/site/CRSurveyAPI' | |
data = { | |
'v' : '1.0', | |
'method': 'submitSurvey', | |
'api_key' : API_KEY, | |
'sso_auth_token':token, | |
'survey_id': API_SURVEY_ID, | |
'cons_first_name' : first_name, | |
'cons_last_name' : last_name, | |
'cons_email' : email_address, | |
'cons_email_opt_in' : email_opt_in.lower(), | |
'cons_city':city, | |
'cons_state':state, | |
'cons_country':country | |
} | |
r = requests.post(url, data = data) | |
root = xml.etree.ElementTree.fromstring(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment