User Guide

Logging in to Breeze 29
Logging in to Breeze
To call most APIs, you must be acting as a logged-in user, so you must call the login API before
you can call most other APIs. (The exceptions—APIs you can call without logging in—are
action-list, common-info, login, and user-accounts.)
When you call the
login API, if the XML results include a status code of ok, the response header
includes a
BREEZESESSION cookie. Capture the cookie and save the results to a variable, such as
loginCookie. Then pass the loginCookie variable as a session parameter in subsequent API
calls.
To log in a user to Breeze:
1.
Create a ColdFusion page with the following content:
<cfif IsDefined("FORM.username")>
<cfset baseurl = "http://breezeserveraddress">
<cfhttp url="#baseurl#/api/
xml?action=login&login=#FORM.username#&password=#FORM.password#"
method="GET"/>
<!-- dump the response into a variable and then into an XML object -->
<cfset response = CFHTTP.FileContent/>
<cfset xml = XMLParse(response)>
<!-- get the BREEZESESSION id from the header-->
<cfset loginHeader = CFHTTP.header>
<cfset loginCookie = ListLast(ListFirst(loginHeader, ";"), "=")>
<cfif xml.XmlRoot.status.XMLAttributes['code'] EQ "OK">
<!-- Login succeeded. -->
<cfhttp url="#baseurl#/api/xml?action=report-my-
meetings&session=#loginCookie#" method="GET"/>
<cfset meetings = CFHTTP.FileContent/>
<cfset meetings_xml = XMLParse(meetings)/>
<cfdump var="#meetings_xml#">
<cfelse>
<!-- Login failed. -->
Login Failed.
</cfif>
<cfelse>
<form action="#CGI.Script_Name#" method="POST">
Username: <input type="text" name="username" size="25"><br>
Password: <input type="password" name="password" size="25"><br>
<input type="submit" name="submit" value="Submit"><br>
</form>
</cfif>
2.
Save the page as login.cfm in the ColdFusion wwwroot directory.
3.
View login.cfm in a browser (use a localhost URL).