| 
	
 | 
 Posted by Charlie King on 08/16/06 17:09 
On 16 Aug 2006 08:07:26 -0700, in 
<1155740846.121540.168860@b28g2000cwb.googlegroups.com> 
(comp.lang.php) "Chung Leong" <chernyshevsky@hotmail.com> wrote: 
 
> Charlie King wrote: 
> > I'm trying to send data to a remote script (a credit card processing 
> > third party) from my site using POST. 
>  
> >From the defunct clp FAQ: 
 
Thanks for this info... it's a shame the FAQ is defunct, it sounds 
like a potentially useful source of info! 
  
> Q. How do I post a form to another site? 
> A. Use stream_context_create() to create a HTTP POST context, then open 
> a connection to the site in question with fopen(), passing the context 
> as the fourth parameter. Use fread() to read the result from the form 
> submission. 
>  
> Example: 
 
[...snip] 
 
Thanks for that, although it seems to have a similar effect to the 
code that I posted, in that it returns the contents of the target 
site, in this case to a file stream, in my case to an array. 
 
What I want to do is to have the browser go to the target page, with 
my variables, by POST.  I.e. exactly as if the user had clicked on a 
[submit] button in a form whose action was POST and url was the target 
site. 
 
> $f = fopen('http://localhost/test.php', 'r', false, $context); 
 
Now that I have a filestream with the remote site's contents in it, 
what do I do with it? 
  
> In PHP 5, a context can also be passed to file_get_contents() and 
> file(). 
 
Unfortunately, I have to work in PHP 4.4.0 without cURL. 
  
> Although stream_context_create() is available since PHP 4.3.0, support 
> for HTTP POST has only become available in 4.3.5. If you are using an 
> older version, you would need the cURL functions or use fsockopen() to 
> open the connection and send the request with fputs(). 
 
So I have everything I need to create a stream context with POST 
support.  Good, now what do I do with it? 
--  
Charlie
 
  
Navigation:
[Reply to this message] 
 |