PHP Classes

Post arguments

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  Post arguments  >  (Un) Subscribe thread alerts  
Subject:Post arguments
Summary:Posting fine but the arguments not working...
Messages:5
Author:Andrew Gill
Date:2008-07-15 16:41:06
Update:2008-07-16 17:11:56
 

  1. Post arguments   Reply   Report abuse  
Picture of Andrew Gill Andrew Gill - 2008-07-15 16:41:06
I can send the post and read the reply body fine. However, the post value arguments are not being sent... I think I am missing something simple in my code. Any ideas?

The code is really short and simple... Any clues much appreciated! :-)

<?php
require("http.php");
set_time_limit(0);
$http=new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=1;

$url="http://localhost/http_test/test_receive.php";

$arguments["RequestMethod"]="POST";
$arguments["PostValues"]=array(
"test2"=>"ZZZZ",
"test"=>"ABC!!");

$arguments["PostFiles"]=array(
"userfile"=>array(
"Data"=>"This is just a plain text attachment file",
"Name"=>"test.txt",
"Content-Type"=>"automatic/name"));

$arguments["Referer"]="http://www.agtest.com/";

$error=$http->GetRequestArguments($url,$arguments);
$error=$http->Open($arguments);
$error=$http->SendRequest($arguments);
$error=$http->ReadReplyHeaders($ReplyHeaders,100);
$error=$http->ReadReplyBody($body,10000);

//print_r (array_keys($ReplyHeaders));
//echo "<br/>BODY = ".HtmlSpecialChars($body);
echo $body;
$http->Close();
?>

  2. Re: Post arguments   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-15 19:43:30 - In reply to message 1 from Andrew Gill
You should call the GetRequestArguments function first because it resets the $arguments array. Only after you can set other request arguments.

  3. Re: Post arguments   Reply   Report abuse  
Picture of Andrew Gill Andrew Gill - 2008-07-16 08:34:11 - In reply to message 2 from Manuel Lemos
Thanks Manuel. Yes, it's working fine now :-)

Can I be bold enough to make a suggestion? It would be very useful to include a very simple example like this in your package. Very handy for new people to your excellent class.

Andy

  4. Re: Post arguments   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-16 16:38:07 - In reply to message 3 from Andrew Gill
Well there is the test_http_post.php example. Isn't that what you mean?

  5. Re: Post arguments   Reply   Report abuse  
Picture of Andrew Gill Andrew Gill - 2008-07-16 17:11:56 - In reply to message 4 from Manuel Lemos
Yes, there is test_http_post.php. However i found it quite difficult to get my head around. Whereas a very simple 20 lines of code with some comments explaining each step would be very useful to a first timer!

Anyway, you've done a superb job with this class and very quick to reply on this forum. Thanks again.