cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

script that renders a download

From: Colleen R. Dick <platypus_at_proaxis.com>
Date: Mon, 21 Aug 2006 10:42:17 -0700

I want to invoke a script on a remote server purpose is to generate a
pdf file and send it to the browser. I wish to capture the pdf in the
background and squirrel it away (since the remote site gives you no
direct option to do that.)

I searched the mailing list--surely someone else has wanted to do this!
One similar question was brushed off by suggesting that the reader read
the docs and examples and use the dead simple one. Another individual
asked a similar question and was advised to "set the options" and do it.
I have read all of the examples and I have read http://us2.php.net/curl
It lists a s**tload of options but it doesn't tell you what they do or
give examples. There are a bunch of functions that aren't documented.
I just wanted you to know that *I have done my homework.* I RTFM and
the FM is just a skoshe sketchy. Also I am using PHP 4.

This is my best guess so far.

$ch =
curl_init("http://www.remotesite.com/generatepdf.php?url=www.myurl.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch,CURLOPT_HEADER, TRUE);
curl_setopt($ch,CURLOPT_BINARYTRANSFER, TRUE); //just guessing
$fh = fopen("/home/www/mysite/demo/tests/testcurl.pdf",'w');
curl_setopt($ch,CURLOPT_FILE, $fh);
$data=curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
unset($ch);
echo $data;

If you call the remote URL directly it sends you a PDF.
 
When I had the HEADER option set it wrote the header to testcurl.pdf
If not it wrote a blank line.
I want the actual PDF file to go to testcurl.pdf. How can I reference
it! People wouldn't keep asking this question if it was so obvious how
to do it!! Please tell me how to fix this script. I have been blind
guessing for the pass half hour. It would probably make a nice edition
to your examples too.
 

Thankyou

 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-08-21