login
67
The following Java example parses the HTTP headers to store the cookie, and then indicates how
it can be passed on for all subsequent requests:
login="[email protected]"
password="abcdefg"
baseurl="http://breeze.example.com/"
URL loginUrl=new URL(b "api/xml?action=login&login=" + login +
"&password=" + password);
URLConnection conn=loginUrl.openConnection();
conn.connect();
InputStream resultStream=conn.getInputStream();
Document doc=new SAXBuilder(false).build(resultStream);
String cookieString=(String) (conn.getHeaderField("Set-Cookie"));
StringTokenizer st=new StringTokenizer(cookieString, "=");
if (st.countTokens() > 1 && st.nextToken().equals("BREEZESESSION")) {
String cookieNext=st.nextToken();
int semiIndex=cookieNext.indexOf(';');
cookie=cookieNext.substring(0, semiIndex);
}
if (cookie == null){
throw new RuntimeException("Couldn't find the Breeze cookie.");
}
To pass the
BREEZESESSION
cookie for all subsequent requests, use the following code:
URLConnection conn=url.openConnection();
conn.setRequestProperty("Cookie", "BREEZESESSION=" + cookie);
conn.connect();
The preceding example sets the password and username variables manually. In a real application,
you would probably create a form that collected the password and username and passed the
variables to the code.
For a ColdFusion example, see
“Logging in to Breeze” on page 29
.
Parameters
account-id
The ID of the account with which the user is associated. This parameter is
optional. If your organization has only one account, don’t specify an
account-id
.
login
The user’s login name, which is usually the user’s e-mail address.
password
The
user’s
password.
Note:
If the
login
or
password
parameter is missing or incorrect, the Breeze server returns a status
code of
no-data
.
Filters
Results cannot be filtered or sorted.
Содержание BREEZE 5
Страница 1: ...Breeze Integration Guide ...
Страница 40: ...40 Chapter 3 Common Tasks ...