Page 2 of 2

Posted: Wed Oct 25, 2006 9:32 am
by Michael Vogel
lexvictory wrote:y are u putting the headers in the posttext variable?
To be honest, I'm not sure what should be done. I tried to do the HTTPSendRequest with the "Fnumber=0650&clicked=2&Snumber=1234567" only, but the result data has been the original page with the number inserted in the input field.

That was the best result I could get until now (playing around for already two nights)

Michael

Posted: Thu Aug 07, 2008 3:33 am
by ricardo
lexvictory wrote:
Bonne_den_kule wrote:How can I make this code to store the cookies ? (the login page I tested said that "the browser" had turned cookies off).

log in to the purebasic forum:

Code: Select all

; 
  ; All stuff for the WinInet lib. 
  ; 
  #INTERNET_OPEN_TYPE_DIRECT = 1 
  #HTTP_ADDREQ_FLAG_ADD = $20000000 
  #HTTP_ADDREQ_FLAG_REPLACE = $80000000 
  #INTERNET_FLAG_SECURE = 0 
  
  ; 
  ; Type of connection (could be FTP Gopher etc). HTTPS is done as HTTP too. 
  ; 
  #INTERNET_SERVICE_HTTP = 3 
  
  ; 
  ; HTTP port is 80, HTTPS (SSL) port is 443. 
  ; 
  #INTERNET_DEFAULT_HTTP_PORT = 80  
  
  ;For httpqueryinfo.
  #HTTP_QUERY_COOKIE = 44

Procedure.s do_post(username.s, password.s) 
  
  ; 
  ; Do NOT include http:// or any other protocol indicator here 
  ; 
  host.s = "purebasic.fr" 
  
  ; 
  ; Everything after the hostname of the server 
  ; 
  get_url.s = "/english/login.php" 
  
  ; 
  ; Holds the result from the CGI/page 
  ; 
  result.s = "" 
  
  ; 
  ; All from the wininet DLL 
  ; 
  ; Be sure your Internet Explorer is up to date! 
  ; 
  open_handle = InternetOpen_("User Agent Info Goes Here",#INTERNET_OPEN_TYPE_DIRECT,"","",0) 
  
  connect_handle = InternetConnect_(open_handle,host,#INTERNET_DEFAULT_HTTP_PORT,"","",#INTERNET_SERVICE_HTTP,0,0) 
  
  request_handle = HttpOpenRequest_(connect_handle,"POST",get_url,"","",0,#INTERNET_FLAG_SECURE,0) 
  
  headers.s = "Content-Type: application/x-www-form-urlencoded" +Chr(13)+Chr(10)  
  
  HttpAddRequestHeaders_(request_handle,headers,Len(headers), #HTTP_ADDREQ_FLAG_REPLACE | #HTTP_ADDREQ_FLAG_ADD) 
  
  ;change this when using a login form other than a phpbb one
  post_data.s = "username="+username+"&password="+password+"&login=Log%20in"; not sure why the submit button text is needed.... but it seemed to make it work for me :lol: 
  
  post_data_len = Len(post_data) 
  
  send_handle = HttpSendRequest_(request_handle,"",0,post_data,post_data_len) 
  
  buffer.s = Space(1024) 
  
  bytes_read.l 
  
  total_read.l 
  
  total_read = 0 
  
  ; 
  ; Read until we can't read anymore.. 
  ; The string "result" will hold what ever the server pushed at us. 
  ; 
  Repeat 
    
    InternetReadFile_(request_handle,@buffer,1024,@bytes_read) 
    
    result + Left(buffer,bytes_read) 
    
    buffer = Space(1024) 
    
  Until bytes_read=0 
  
  
  ;- uncomment the following when you want to get the cookie data - not sure if it works or not.....
  ;buffer.s = Space(#MAX_PATH)
  ;headernum = 0
  ;length = Len(buffer)
  ;HttpQueryInfo_(request_handle, #HTTP_QUERY_COOKIE, @buffer, @length, @headernum)
  ;Debug buffer
  
 ProcedureReturn result
  
EndProcedure 







SetClipboardText(do_post("YOUR USERNAME", "YOUR PASSWORD"))





MessageRequester("Done", "Paste text into your text editor!")

remember to put in your username and password :lol:
Does anyone knows how i can not only log but make a post to this phpbb forum using PB?

Re: Simulating HTTP(S) POST

Posted: Mon Oct 12, 2009 12:38 am
by theghost
doesn't work...

Re: Simulating HTTP(S) POST

Posted: Mon Oct 12, 2009 6:26 am
by lexvictory
theghost wrote:doesn't work...
because the login page has changed with the new version of phpBB most likely (the example that uses the forum that is)