All day trying to solve this, it does not work anymore. I can log in the forum, read and delete private messages, but to send the business will not.
I need to send a private message through my software made in delphi (xe6). The forum uses phpbb3.
From what I've analyzed, phpbb sends the following to send the message:
Post URL: http://site.com/ucp.php?i=pm&mode=compose&action=post&sid=xxxxx
Post Data:
username_list=
icon=0
subject=assunto
message=texto
address_list[u][2]=to
lastclick=xxxx
status_switch=0
post=Submit
attach_sig=on
creation_time=xxxx
form_token=xxx
The values xxx should be captured the moment you send the message, and my program captures these values correctly, because I put it to save the page and I manually check if the values were correct, and they are.
My code:
procedure Envia();
var
form_token, cr_time, sid: string;
pp: TStringList;
begin
//baixo a pagina para pegar os valores (form_token e etc)
FPageSource.Text := FCon.Get('http://localhost/ucp.php?i=pm&mode=compose&u=2
//form token
form_token := TRegEx.Match(FPageSource.Text, 'form_token" value="(\w+)"').Groups[1].Value;
//creation time
cr_time := TRegEx.Match(FPageSource.Text, 'creation_time" value="(\w+)"').Groups[1].Value;
//sid
sid := TRegEx.Match(FPageSource.Text, 'sid=(\w+)').Groups[1].Value;
//data
pp := TStringList.Create;
pp.Add('username_list=');
pp.Add('icon=0');
pp.Add('subject=assunto');
pp.Add('message=mensagem');
pp.Add(HttpEncode('address_list[u][2]') + '=to');
pp.Add('lastclick=' + cr_time);
pp.Add('status_switch=0');
pp.Add('post=Submit');
pp.Add('attach_sid=on');
pp.Add('creation_time=' + cr_time);
pp.Add('form_token=' + form_token);
//enviamos
FPageSource.Text := FCon.Post('http://localhost/ucp.php?i=pm&mode=compose&action=post&sid=' + sid, pp);
//O resultado contido em FPageSource é na caixa de entrada das mensagens
//como se eu NÃO estivesse enviado nada, completamente ignorado.
end;
Final considerations:
- FCon = TIdHttp
- FPageSource = TStringList
- HttpEncode = unit function HttpApp