Meh.
First of all, you'll need to grab a login cookie.
Here's something I wrote in Python:
def get_login_cookie(username, password):
body = urllib.urlencode('user=%s&passwrd=%s&cookieneverexp=1' % (username, password))
headers = {
'Host': 'forum.blockland.us',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0',
'Connection': 'close',
'Referer': 'http://forum.blockland.us/index.php?action=login;wap2',
'Content-Type': 'application/x-www-form-urlencoded'
}
urllib2.urlopen(urllib2.Request('http://forum.blockland.us/index.php?action=login2;wap2', body, headers))
So basically, you'll need to send a POST request with some specific headers to
http://forum.blockland.us/index.php?action=login2;wap2 with the following data:
user=username&passwrd=password&cookieneverexp=1Once you get some data, look through the headers for a
Set-Cookie header and do stuff with that. You pretty much only need to do this once because of
cookieneverexp, but you can do it again if the session somehow becomes invalid.
When you need to post something, such as a reply to a topic, first do a GET for
http://forum.blockland.us/index.php?action=post;topic=195212.0;num_replies=8;wap2 (that's for this topic) with your cookie passed as a
Cookie header and look through all the
input elements. They have some information (name, value) that you'll need to save, such as
sc and
seqnum.
Then, change some of the values you got, such as
message and send a POST request to
http://forum.blockland.us/index.php?action=post2;start=0;board=25 (still taking this topic as example destination) with your cookie passed as a
Cookie header. For the data, you need to use the information you saved previously. Build it as follows:
var_name=var_value&something_else=dunno&foo=barIt's important that you pass all the information you got in the GET request previously or you might session errors or start a new topic instead of simply making a reply.
All the links I stated except for login depend on where you want to post. You can get the URL for the initial GET request from the REPLY button, and the URL for the POST request from the
action attribute of the
form element on the page you got from the initial GET request.