RE: [PHP] Faking a form POST

2002-04-16 Thread .ben

Thanks to everyone who helped out with this question, got it all working
nicely now.  Will credit you all on finished site.

Cheers,

 .ben

> -Original Message-
> From: Steve Dix [mailto:[EMAIL PROTECTED]]
> Sent: 16 April 2002 12:26
> To: .ben
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP] Faking a form POST
>
>
> On 16 Apr 2002 at 12:22, .ben wrote:
>
> > hmm, i was kinda after an in-process component like the ASP components
> > ASPHTTP (http://www.ServerObjects.com) and ASPTear
> > (http://www.alphasieraapapa.com).
> >
> > cheers tho,
> >
> >  .b
> >
>
> Try this :
>
> You will have to encode your data in a similar manner to a get
> method, only without using the ?  ie
>
> to send hello = 1,  mouse=brown
>
> &hello=1&mouse=brown
>
> in $data_to_send
>
>  function PostToHost($host, $path, $data_to_send)
> {
>   $fp = fsockopen($host,80);
>   fputs($fp, "POST $path HTTP/1.1\n");
>   fputs($fp, "Host: $host\n");
>   fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
>   fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
>   fputs($fp, "Connection: close\n\n");
>   fputs($fp, $data_to_send);
>   while(!feof($fp))
>   {
>   echo fgets($fp, 128);
>   }
>   fclose($fp);
> }
>
> ?>
> Steve Dix>==<[EMAIL PROTECTED]
> http://www.stevedix.de/
> http://www.snorty.net/
> http://www.mp3.com/simpletons
> http://www.geocities.com/motorcity/2706
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Faking a form POST

2002-04-16 Thread .ben

Erik, thanks for this.  Works great, 

 .b

> -Original Message-
> From: Erik Price [mailto:[EMAIL PROTECTED]]
> Sent: 16 April 2002 14:30
> To: [EMAIL PROTECTED]
> Cc: PHP
> Subject: Re: [PHP] Faking a form POST
> 
> 
> 
> On Monday, April 15, 2002, at 09:36  PM, .ben wrote:
> 
> > Hi.  Does anyone know how to POST data to another script as if a form 
> > had
> > done so?  I want to POST some data to a script on another site and 
> > retrieve
> > the data that is returned so i can poick it apart, i did it in ASP 
> > using a
> > 3rd party component... just wondering if the same could be done in PHP.
> >
> > Any help appreciated.
> 
> This function will look a lot prettier once you've copied it into a text 
> editor that can handle > 80 columns -- or you can remove the comments.
> 
>  From the archives:
> 
> # ===
> # PostToHost($host, $path, $data_to_send)
> # ---
> # "It is a trivial little function."
> # -Rasmus
> # ===
> 
> function PostToHost($host, $path, $data_to_send)
> {
>   $fp = fsockopen($host,80);  
>   // $fp now points 
> to the "file" opened 
> by fsockopen
>   fputs($fp, "POST $path HTTP/1.0\n");
>   // write the first header, with 
> the path and the protocol (annotations suggest using 1.0 over 1.1)
>   fputs($fp, "Host: $host\n");
>   // write the hostname line 
> of the header
>   fputs($fp, "Content-type: 
> application/x-www-form-urlencoded\n");// write 
> the encoding type line of the header
>   fputs($fp, "Content-length: " . strlen($data_to_send) . 
> "\n");// write 
> the content-length of data to send
>   fputs($fp, "Connection: close\n\n");
>   // close the connection, and 
> a blank line
>   fputs($fp, $data_to_send);  
>   // write the data 
> to send (in POST variable 
> form)
>   while(!feof($fp)) { 
>   // until 
> the end of the "file", eat 128 
> bytes at a time
>   echo fgets($fp, 128);
>   }
>   fclose($fp);
>   // close the "file"
> }
> 
> 
> 
> 
> 
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Faking a form POST

2002-04-16 Thread Erik Price


On Monday, April 15, 2002, at 09:36  PM, .ben wrote:

> Hi.  Does anyone know how to POST data to another script as if a form 
> had
> done so?  I want to POST some data to a script on another site and 
> retrieve
> the data that is returned so i can poick it apart, i did it in ASP 
> using a
> 3rd party component... just wondering if the same could be done in PHP.
>
> Any help appreciated.

This function will look a lot prettier once you've copied it into a text 
editor that can handle > 80 columns -- or you can remove the comments.

 From the archives:

# ===
# PostToHost($host, $path, $data_to_send)
# ---
# "It is a trivial little function."
# -Rasmus
# ===

function PostToHost($host, $path, $data_to_send)
{
$fp = fsockopen($host,80); 
 // $fp now points to the "file" opened 
by fsockopen
fputs($fp, "POST $path HTTP/1.0\n");   
 // write the first header, with 
the path and the protocol (annotations suggest using 1.0 over 1.1)
fputs($fp, "Host: $host\n");   
 // write the hostname line of the header
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");// 
write 
the encoding type line of the header
fputs($fp, "Content-length: " . strlen($data_to_send) . "\n");  // 
write 
the content-length of data to send
fputs($fp, "Connection: close\n\n");   
 // close the connection, and 
a blank line
fputs($fp, $data_to_send); 
 // write the data to send (in POST variable 
form)
while(!feof($fp)) {
 // until the end of the "file", eat 128 
bytes at a time
echo fgets($fp, 128);
}
fclose($fp);   
 // close the "file"
}





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Faking a form POST

2002-04-16 Thread Shaun Martinec

Check out the php docs for curl: http://www.php.net/manual/en/ref.curl.php
Maybe it's more of what you need. I use it with paypay autopay and such.

"Steve Dix" <[EMAIL PROTECTED]> wrote in message
3CBC2652.2995.4CD93C@localhost">news:3CBC2652.2995.4CD93C@localhost...
> On 16 Apr 2002 at 12:22, .ben wrote:
>
> > hmm, i was kinda after an in-process component like the ASP components
> > ASPHTTP (http://www.ServerObjects.com) and ASPTear
> > (http://www.alphasieraapapa.com).
> >
> > cheers tho,
> >
> >  .b
> >
>
> Try this :
>
> You will have to encode your data in a similar manner to a get
> method, only without using the ?  ie
>
> to send hello = 1,  mouse=brown
>
> &hello=1&mouse=brown
>
> in $data_to_send
>
>  function PostToHost($host, $path, $data_to_send)
> {
> $fp = fsockopen($host,80);
> fputs($fp, "POST $path HTTP/1.1\n");
> fputs($fp, "Host: $host\n");
> fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
> fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
> fputs($fp, "Connection: close\n\n");
> fputs($fp, $data_to_send);
> while(!feof($fp))
> {
> echo fgets($fp, 128);
> }
> fclose($fp);
> }
>
> ?>
> Steve Dix>==<[EMAIL PROTECTED]
> http://www.stevedix.de/
> http://www.snorty.net/
> http://www.mp3.com/simpletons
> http://www.geocities.com/motorcity/2706
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Faking a form POST

2002-04-16 Thread Steve Dix

On 16 Apr 2002 at 12:22, .ben wrote:

> hmm, i was kinda after an in-process component like the ASP components
> ASPHTTP (http://www.ServerObjects.com) and ASPTear
> (http://www.alphasieraapapa.com).
> 
> cheers tho,
> 
>  .b
> 

Try this :

You will have to encode your data in a similar manner to a get 
method, only without using the ?  ie

to send hello = 1,  mouse=brown

&hello=1&mouse=brown

in $data_to_send


Steve Dix>==<[EMAIL PROTECTED]
http://www.stevedix.de/
http://www.snorty.net/
http://www.mp3.com/simpletons
http://www.geocities.com/motorcity/2706


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Faking a form POST

2002-04-16 Thread .ben

hmm, i was kinda after an in-process component like the ASP components
ASPHTTP (http://www.ServerObjects.com) and ASPTear
(http://www.alphasieraapapa.com).

cheers tho,

 .b

> -Original Message-
> From: jon [mailto:[EMAIL PROTECTED]]
> Sent: 16 April 2002 05:10
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Faking a form POST
>
>
> If you're on windows, you can use a program called Achilles. It acts as a
> proxy and lets you edit the data you send from your browser...
>
> Don't have a URL handy, but it's easy to find.
>
>   -- jon
>
>
>
>
> -Original Message-
> From: .ben [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 15, 2002 9:36 PM
> To: PHP
> Subject: [PHP] Faking a form POST
>
>
> Hi.  Does anyone know how to POST data to another script as if a form had
> done so?  I want to POST some data to a script on another site
> and retrieve
> the data that is returned so i can poick it apart, i did it in ASP using a
> 3rd party component... just wondering if the same could be done in PHP.
>
> Any help appreciated.
>
> Cheers,
>
>  .ben
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php