-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (26 loc) · 1008 Bytes
/
test.py
File metadata and controls
32 lines (26 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: UTF-8 -*-
from cakeapi import API
import json # Not needed. Used only for pretty printing the JSON object
# Initialize the API Object by parsing your API Key
apiobj = API('YourApiKey')
# Log in
login_params = {
'email' : 'some@email.com',
'password' : 'abc123'
}
# Pass the params to the API as an array['Class','Method'] and a dictionary with params
response = apiobj.call(['User', 'login'], login_params)
print json.dumps(response, indent=2)
# Subscribing an email to a list with custom fields
subscribe_params = {
'user_key' : 'theUserKey',
'list_id' : 'theListId',
'client_id' : 'theClientId',
'email' : 'theEmailToSusbcribe',
'data[First Name]' : 'FirstName',
'data[Last Name]' : 'LastName',
'data[Phone #]' : '514826936',
'data[Endereço]' : '1234 Rnd Street'
}
response = apiobj.call(['List', 'subscribeEmail'], subscribe_params)
print json.dumps(response, indent=2)