tcamps
Non-stop Poster
- Reaction score
- 109
I have a script that does a bunch of webpage scraping that is typically ran in the background as the player goes about their business. In some cases the player may be logged out by a co, and the script starts throwing errors since the session expired. The player thinks the script is broken because of the errors.
I'd like to detect when the user's session has expired, though I haven't found a "good" method for doing this.
Any webpage requests will be redirected to TW home page with HTTP 302, but this response isn't fully captured as the AJAX data only shows generic "error" text with status code 0. An alternative is to poke some AJAX API ie /game.php?screen=overview&ajax=map_info&village=0 and checking if the response object shows a session expiration error. I'd rather avoid this since TW would be seeing a lot of errors on their end since I'll likely be querying a nonexistent village or some other nonexistent data depending on the endpoint.
Is there any consistent API that I can query to check session status?
I'd like to detect when the user's session has expired, though I haven't found a "good" method for doing this.
Any webpage requests will be redirected to TW home page with HTTP 302, but this response isn't fully captured as the AJAX data only shows generic "error" text with status code 0. An alternative is to poke some AJAX API ie /game.php?screen=overview&ajax=map_info&village=0 and checking if the response object shows a session expiration error. I'd rather avoid this since TW would be seeing a lot of errors on their end since I'll likely be querying a nonexistent village or some other nonexistent data depending on the endpoint.
Is there any consistent API that I can query to check session status?