Send private message with phpbb - Delphi -


i've spent hours trying understand why doesn't work, no success ;(

i want send private messages delphi application.

i can login, read , delete messages, can't manage send messages (my forum use phpbb3).

analysing post data, got this:

post url: http://example.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 xxx values need before send. i've manually checked values, , correct.

my code:

procedure envia(); var   form_token, cr_time, sid: string;   pp: tstringlist; begin   //download page values (token, sid...)   fpagesource.text := fcon.get('http://example.com/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);    //send   fpagesource.text := fcon.post('http://example.com/ucp.php?i=pm&mode=compose&action=post&sid=' + sid, pp);    //the result in fpagesource inbox, post data   //ignored phpbb ;(  end; 

note:

  • fcon = tidhttp
  • fpagesource = tstringlist
  • httpencode = function in httpapp unit
  • using delphi xe6

-- i've sent message opera , captured post data fiddler, here image. can see, data structure same, why isn't working ?

the main problem simple - wait time (spam protection). plus should add user first - 1 more request.

this code should work fine

  s:=fcon.get('http://.../ucp.php?i=pm&mode=compose');    pp.add('username_list=usertoadd');   pp.add('add_to=add');   pp.add('icon=0');   pp.add('subject=');   pp.add('addbbcode20=100');   pp.add('message=');   pp.add('lastclick='+...);   pp.add('status_switch=0');   pp.add('creation_time='+...);   pp.add('form_token='+...);    s:=fcon.post('http://.../ucp.php?i=pm&mode=compose&action=post&sid=...', pp);    sleep(2000); // <-- wait here    pp.clear;   pp.add('username_list=');   pp.add('icon=0');   pp.add('subject=xx');   pp.add('addbbcode20=100');   pp.add('message=yy');   pp.add('address_list[u][2]=to');   pp.add('lastclick='+...);   pp.add('status_switch=0');   pp.add('post=submit');   pp.add('attach_sid=on');   pp.add('creation_time='+...);   pp.add('form_token='+...);  // new 1    s:=fcon.post('http://.../ucp.php?i=pm&mode=compose&action=post&sid=...', pp); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -