Although it has been years since I have worked in classic ASP, I recently addressed a question on the Infusionsoft Developer Forum in which the original poster referred to me as a genius for solving his problem. How could I not create an entire blog from that single comment?
Below is a sample of the ASP code required to create a contact. This example uses VBScript and assumes that the ASP XML-RPC library is already installed on the web server.
<!–#include virtual="/aspxmlrpc/code/xmlrpc.asp" –>
Dim key, url, contact, contactId
Dim contactParamList, optinParamList
‘key is the encrypted API key you got from Infusionsoft
key = "theKey"
‘URL is the API Url you got from Infusionsoft
url = "https://theApp.infusionsoft.com:443/api/xmlrpc"
‘Scripting.Dictionary used to represent XML-RPC struct
Set contact = Server.CreateObject("Scripting.Dictionary")
contact.Add "FirstName", "Barney"
contact.Add "LastName", "Fife"
contact.Add "Email", "firstname.lastname@example.org"
contact.Add "DateCreated", Date
‘contactParamList will hold parameters to the service call
contactParamList(0) = key
Set contactParamList(1) = contact
‘Make the API call. The result is the ID of the new contact
contactId = xmlRPC (url, "ContactService.add", contactParamList)
‘Clean up and print results
Set contact = Nothing
optinParamList(0) = key
optinParamList(1) = "email@example.com"
optinParamList(2) = "Opted in through API"
‘Call method from xmlrpc.asp include file
xmlRPC url, "APIEmailService.optIn", optinParamList
ContactService.add method will add a contact to your application, which essentially has the same affect as the
DataService.add method with the only exception being the execution of a configurable Action Set that is executed when a contact is added.
Another point to note is the final API call to
APIEmailService.optIn method. This call is not required when creating a new contact, as the
ContactService.add method will automatically single opt-in a user. If on the other hand, we were to have updated that email address for a contact with the
ContactService.update method, the email address would need to have the
APIEmailService.optIn method run.
Links to the XML-RPC libraries can be found on the Resources page.