BuzzerBeater Forums

BBAPI Support > handle the cookies and login stuff in java

handle the cookies and login stuff in java

Set priority
Show messages by
This Post:
00
54052.6 in reply to 54052.3
Date: 12/13/2009 1:32:54 AM
Overall Posts Rated:
00
Dr. Jàn Ïtor™'s link to the cookie handling is probably not the best method to use for with Java.

If you have a look at the Java bug database you will see the CookieManager in Java 6 is very buggy. I couldn't get it to work for BB but could on othersites. (Java bugs no BB's fault)

The best method is to go old skool and handle the cookies yourself
see:
http://www.rgagnon.com/javadetails/java-0092.html

I got this method working so it does work ;p

Good Luck!

From: jantzen
This Post:
00
54052.7 in reply to 54052.6
Date: 12/13/2009 4:33:15 PM
Overall Posts Rated:
5353
I have tested with http client from apache and it has been pretty easy.

No handling of the cookies as long as you have the connection open.

So take a look at it: http://hc.apache.org/httpclient-3.x/
I think I had this sniplet laying around.

package dk.jantzens.bbma;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class GetCookiePrintAndSetValue {

public static void main(String args[]) throws Exception {

HttpClient client = new DefaultHttpClient();
client.getParams().setParameter("http.useragent", "bbam");

HttpGet method = new HttpGet(
"http://www.buzzerbeater.com/BBAPI/login.aspx?login=USERNAME&code=CODE");
HttpGet method2 = new HttpGet(
"http://www.buzzerbeater.com/BBAPI/roster.aspx");
HttpResponse httpResponse = null;
try {
httpResponse = client.execute(method);
httpResponse = client.execute(method2);
// System.out.println(httpResponse.getText());
} catch (Exception e) {
System.err.println(e);
} finally {
method.abort();
}
}
}