It is currently Sat Dec 05, 2020 6:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: HttpRequest POST simple not works
PostPosted: Sun Oct 04, 2020 7:34 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Hello at all

I have not really understand the POST method :oops:

I have this php code
Code:
function Ajoute($Texte)
   {
      $Ecriture = fopen("ListeTextes.txt", "a");
      fputs($Ecriture, "\n" . $Texte);
      fclose($Ecriture);
   }
       
if (isset($_POST['Action']) && isset($_POST['Valeur']))
   {
      $Action = $_POST['Action'];
      $Valeur = $_POST['Valeur'];
            
      if ($Action == "Ajoute")
      {
         Ajoute($Valeur);
      }

   }


And when i use this PB code that not works :|

Code:
Url$ = "http://Mysite/index.php"

InitNetwork()
HttpRequest = HTTPRequest(#PB_HTTP_Post, Url$, "Action=Ajoute&Valeur=hello")

If HttpRequest
 
 Debug "Status: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
 Debug "Réponse: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
 FinishHTTP(HTTPRequest)
 
Else

 MessageRequester("Erreur", "La requete n'a pas été envoyée")
 
EndIf
 


Thanks and have a good day

_________________
ImageThe happiness is a road...
Not a destination


Last edited by Kwai chang caine on Sun Oct 04, 2020 8:12 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest POST
PostPosted: Sun Oct 04, 2020 7:54 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
Maybe your server needs the Content-Length:
Code:
NewMap Header$()

Url$ = "http://myip/index.php"
Post$ = "Action=Ajoute&Valeur=hello"

Header$("Content-Length") = Str(StringByteLength(Post$, #PB_UTF8))

InitNetwork()
HttpRequest = HTTPRequest(#PB_HTTP_Post, Url$, Post$, 0, Header$())

If HttpRequest
 
  Debug "Status: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "Réponse: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
  FinishHTTP(HTTPRequest)
 
Else
 
  MessageRequester("Erreur", "La requete n'a pas été envoyée")
 
EndIf


Or is there a Cookie required?


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest POST
PostPosted: Sun Oct 04, 2020 8:12 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Decidedly you are the king of HTTP :shock:
That works now , thanks a lot INFRATEC and have a good night 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest POST simple not works [Resolved]
PostPosted: Mon Oct 05, 2020 10:02 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 649
Location: Germany, Saarbrücken
Hm, this would be a nice feature request. In general it makes no sense to set Post data but write no Content-Length header. It is useful for streaming data but in this case HTTPRequest always sends a predefined request with a defined length. it would be nice if the Content-Length would be set automatically.

_________________
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.


Top
 Profile  
Reply with quote  
 Post subject: Re: HttpRequest POST simple not works [Resolved]
PostPosted: Mon Oct 05, 2020 1:33 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14180
Location: France
I agree


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye