> Thanks Russ and Dave-- that answers the bulk of my question. > If anyone has a blog off the top of their head demonstrating > this, now would be a perfect time to mention it. :)
I don't know of a blog entry on this, but here's a code sample demonstrating the use of CFHTTP to work with the Connect (formerly Breeze) API: <cfcomponent extends="breezeobj" hint="This component is used to connect to the Breeze server. All other components within this package rely on this component to connect. An instance of this component is required as an argument when creating other components within the package."> <cfset instance = StructNew()> <cfset instance.breezeServerURL = ""> <cfset instance.breezeServerQueryString = "api/xml?"> <cfset instance.accesskey = ""> <cfset instance.logincookie = ""> <cfset instance.lastHTTPResponse = ""> <cfset instance.connectionStatus = false> <cffunction name="init" access="public" returntype="breeze" output="false" hint="This method must be called upon instantiation of the component."> <cfargument name="username" type="string" required="yes"> <cfargument name="password" type="string" required="yes"> <cfargument name="URL" type="string" required="yes"> <cfset var postvars = StructNew()> <cfset var HTTPResponse = ""> <cfset instance.breezeServerURL = Arguments.URL> <cfset postvars["action"] = "login"> <cfset postvars["login"] = Arguments.username> <cfset postvars["password"] = Arguments.password> <cfset HTTPResponse = sendRequest(postvars)> <cfset instance.logincookie = ListLast(ListFirst(sendRequest(postvars).ResponseHeader["Set-Cookie"], ";"), "=")> <cfreturn this> </cffunction> <cffunction name="sendRequest" access="package" returntype="struct" output="false" hint="This method is used to communicate via HTTP with the Breeze server."> <cfargument name="postvars" type="struct" required="yes"> <cfset var HTTPResponse = ""> <cfset var HTTPURL = instance.breezeServerURL & instance.breezeServerQueryString> <cfset var i = ""> <cftry> <cfhttp url="#HTTPURL#" method="post" timeout="30" throwonerror="yes"> <cfif Len(instance.logincookie)> <cfhttpparam type="Header" name="Cookie" value="BREEZESESSION=#instance.logincookie#"> </cfif> <cfloop collection="#Arguments.postvars#" item="i"> <cfhttpparam type="Formfield" name="#LCase(i)#" value="#Arguments.postvars[i]#"> </cfloop> </cfhttp> <cfset instance.lastHTTPResponse = Duplicate(CFHTTP)> <cfcatch type="any"> <cfthrow type="breeze.HTTPError" message="Unable to communicate with Breeze Server" detail="No details available."> </cfcatch> </cftry> <cftry> <cfset instance.lastHTTPResponse.XMLContent = XmlParse(instance.lastHTTPResponse.FileContent)> <cfcatch type="any"> <cfthrow type="breeze.invalidResponse" message="Invalid response received from Breeze Server" detail="#instance.lastHTTPResponse.FileContent#"> </cfcatch> </cftry> <cfreturn instance.lastHTTPResponse> </cffunction> <cffunction name="getBreezeServerURL" access="package" returntype="string" output="false"> <cfreturn instance.breezeServerURL> </cffunction> <cffunction name="setCookie" access="public" returntype="boolean" output="true" hint="This method is used to log a user's browser into the Breeze server."> <cfset var domain = CreateObject("component", "components.breeze.util").parseURL(instance.breezeServerURL).domain> <cfcookie name="BREEZESESSION" value="#instance.logincookie#" domain=".#domain#"> <cfreturn true> </cffunction> <cffunction name="addSessionTokenToURL" access="package" returntype="string"> <cfargument name="url" required="yes" type="string"> <cfset var sessionToken = ""> <cfif Arguments.url contains "?"> <cfset sessionToken = "&"> <cfelse> <cfset sessionToken = "?"> </cfif> <cfset sessionToken = sessionToken & "session=" & instance.logincookie> <cfreturn Arguments.url & sessionToken> </cffunction> <cffunction name="getConnectionStatus" access="public" returntype="boolean" output="false"> <cfreturn instance.connectionStatus> </cffunction> </cfcomponent> The relevant parts are the init method, which uses sendRequest to make the initial connection to the server, retrieves the cookie and stores it in the object instance, and the sendRequest method, which is responsible for making all the HTTP requests to Connect. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Training: Adobe/Google/Paperthin Certified Partners http://training.figleaf.com/ WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers! http://www.webmaniacsconference.com/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:299843 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4