Available playersTop players Chat Forum External sites: Wiki
|
|
|
|
I'm interested in trying my hand at a bot, but I've kind of stumbled at the first hurdle. I've grabbed a copy of the example bot, not changed a thing, compiled it, ran it with the right arguments (username then apitoken) but get a 401 error (well, an IOException because of it) every time.
What am I doing wrong? I've tried creating a new apitoken, checked the username is correct. When I debug I can see it's calling Eliza.httpRequest with the right URL (http://test.weewar.com/api1/headquarters), right username and right password. If you fancy trying to replicate it, my bot-to-be's username is ai_RichBot and the current apitoken is RrjyTTuj8QmSEa3QJUHz5Cyu9 . Any help would be appreciated! java.io.IOException: Server returned HTTP response code: 401 for URL: http://test.weewar.com/api1/headquarters at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1296) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1290) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:944) at Eliza.httpRequest(Eliza.java:57) at Eliza.headquarterGames(Eliza.java:80) at WeirdoBot.run(WeirdoBot.java:71) at java.lang.Thread.run(Thread.java:619) |
|
|
|
|
|
Ok now this is odd!
Looking at the source for java.net.URLConnection, it turns out every single getHeaderField method does nothing - they just immediately return null or an empty collection. What gives? And why does the example bot bother using it? |
|
|
|
|
|
Try using weewar.com instead of test.weewar.com, unless that was your intention. Not sure if that would fix it, but it might help.
This message was edited 1 time. Last update was at 10/04/2009 00:16:46 |
|
|
|
|
| Spade's right I just hit the link and used your bot name and token and could not log in, when i removed the 'test.' i was ab;e to log in without any problems | |
|
|
|
|
Fantastic guys, thanks!
It's test.weewar.com that's default in the code, but I don't have an account there. Still, bit weird that sun's java api has unimplemented methods... |
|