Send a private message phpbb

Asked

Viewed 58 times

0

All day trying to solve this, no more. 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 via my software in Delphi (xe6). The forum uses phpbb3.

From what I 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 well, because I put it to save the page and I manually check if the values were correct, and 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 Httpapp function
  • You did not specify a value in the parameter username_list. In the address_list[u][2] Are you sure this is it? According to documentation, should pass a array of arrays, the first level must have the u for the user and/or g for group, in PHP it would be like this: 'address_list' => array ('u' => array($user->data['user_id'] => 'to')).

  • @qmechanik but the strange thing is that by the browser the username_list is not used, is left blank. Look at the image, sent the message to the id user 60 using Opera (captured with Fiddler). Imagery

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.