-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathapi.asp
More file actions
81 lines (65 loc) · 3.12 KB
/
api.asp
File metadata and controls
81 lines (65 loc) · 3.12 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!--#include virtual="aspxmlrpc/code/xmlrpc.asp" -->
<%
'ASP examples for using the Infusion API. The library used above
'can be found at http://aspxmlrpc.sourceforge.net/
'This example will perform three functions:
' 1. Add a new contact record
' 2. Add the newly created contact to a group
' 3. Look up a list of all contacts that belong to that group
'key is the encrypted API key you got from Infusion Software
key = "6ae189d497cd486b9db53793ccf98646"
'URL is the API Url you got from Infusion Software
url = "https://marty.infusionsoft.com:443/api/xmlrpc"
'--------------------------- ADD CONTACT ----------------------------
'---------------------------------------------------------------------------
'This function will add a contact to the database
Dim contact
'Scripting.Dictionary object is used to represent the XML-RPC struct
Set contact = Server.createObject("Scripting.Dictionary")
contact.Add "FirstName", "ASP John"
contact.Add "LastName", "ASP Doe"
contact.Add "Email", "eric@infusionsoft.com"
contact.Add "DOB", Date
'paramList will hold parameters to the service call
ReDim paramList(3)
paramList(0) = key
paramList(1) = "Contact" 'The table we are adding to
Set paramList(2) = contact
'Make the API call. The result is the ID of the new contact
contactId = xmlRPC (url, "DataService.add", paramList)
'Debugging information
Response.Write(functionToXML ("DataService.add", paramList))
'Clean up and print results
Set contact = Nothing
Response.Write("New Contact ID is " & contactId & "<BR>")
'--------------------------- ADD TO GROUP ----------------------------
'----------------------------------------------------------------------------
'This function will take the contact added above and add it to group 97
groupId = 97
ReDim paramList(3)
paramList(0) = key
paramList(1) = contactId
paramList(2) = groupId
success = xmlRPC (url, "ContactService.addToGroup", paramList)
Response.Write("Contact was added to group " & success & "<BR>")
'--------------------------- LIST IN GROUP ----------------------------
'-----------------------------------------------------------------------------
'This will list all contact ids that belong to group 97
ReDim paramList(7)
paramList(0) = key
paramList(1) = "ContactGroupAssign" 'The table that stores the information we are looking for
paramList(2) = 50 'The limit to the # of records returned
paramList(3) = 1 'What page of results to view
paramList(4) = "GroupId" 'The field we will be searching on
paramList(5) = groupId 'The criteria for that field
Dim fields(2)
fields(0) = "ContactGroup" 'Fields to return in the query
fields(1) = "ContactId"
paramList(6) = fields
contacts = xmlRPC (url, "DataService.findByField", paramList)
'The contacts variable will be a list that contains struct (or dictionaries)
For Each assignment in contacts
'assignment variable is a dictionary
Response.Write("Contact " & assignment("ContactId") & " was assigned to " & assignment("ContactGroup") & "<BR>")
Next
%>