I4A API ColdFusion Example: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
This example shows the basics of making a call to the API and returning the results. | This example shows the basics of making a call to the API and returning the results. | ||
<pre> | <pre> | ||
<source lang=" | <source lang="cfm"> | ||
<cfoutput> | <cfoutput> | ||
<cfset wUrl = "http://www.mydomain.com/i4a/utilities/authenticate.cfc?wsdl"> | <cfset wUrl = "http://www.mydomain.com/i4a/utilities/authenticate.cfc?wsdl"> | ||
| Line 26: | Line 26: | ||
<cfdump var="#contact#" label="Decoded Json"> | <cfdump var="#contact#" label="Decoded Json"> | ||
</ | </cfoutput> | ||
</source> | </source> | ||
</pre> | </pre> | ||
[[Category:API]] | [[Category:API]] | ||
Revision as of 20:40, 21 September 2022
This example shows the basics of making a call to the API and returning the results.
<source lang="cfm">
<cfoutput>
<cfset wUrl = "http://www.mydomain.com/i4a/utilities/authenticate.cfc?wsdl">
<cfset username = "*********" />
<cfset password = "*******" />
<cfset site_token = "*******-****-****-************" />
<cfset search_url = "http://www.mydomain.com/i4a/api/json/membership.contacts/lastname%20like%20l/" />
<cfset myConn = createObject("webservice",wUrl) />
<cfset admin = myConn.authenticateAdmin(username,password,site_token) />
<cfdump var ="#admin#" />
<cfset adminXML = xmlParse(admin) />
<cfdump var="#adminXML#">
<cfset authKey = adminXML.admin.XmlAttributes.authKey>
API URL=#search_url#<br>
<cfhttp url="#search_url##authKey#" method="GET" result="result" charset="utf-8" />
<cfset contactJSON = result.FileContent />
<hr>Json Packet:<br>
<cfdump var="#contactJSON#">
<hr>
<cfset contact = deserializejson(contactJSON) />
<cfdump var="#contact#" label="Decoded Json">
</cfoutput>
</source>