Sarah Mirza | 1 Jul 01:43 2004

Curl + PDF Download


Hi,

I want to download the pdf document from a webpage and store it in my database. 

http://v3.espacenet.com/pdfdoc?DB=EPODOC&IDX=WO03075629&QPN=WO03075629

This is the page from which I want to pick up the document. Is there any way to do this ?

Thanks!
-Sarah

Daniel Stenberg | 1 Jul 08:24 2004
Picon

Re: Curl + PDF Download

On Wed, 30 Jun 2004, Sarah Mirza wrote:

> I want to download the pdf document from a webpage and store it in my 
> database.
>
> http://v3.espacenet.com/pdfdoc?DB=EPODOC&IDX=WO03075629&QPN=WO03075629
>
> This is the page from which I want to pick up the document. Is there any way 
> to do this ?

Yes, you create a curl handle, set the options and then download it.

If the server requires cookies or a login or similar you need to provide all 
that first.

You'll find a few examples that might offer inspiration here:

 	http://curl.haxx.se/libcurl/php/examples/

--

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html

Antonio Navarro Navarro | 6 Jul 10:32 2004
Picon

Slashes and quotes

Hi all !

I'm making an application in Curl that sends XML using POST. The data
is received with the quotes backslashed :

$url="http://server.com/process.php"
$xmlstream='xml=<?xml version="1.0" encoding="UTF-8"?<test data="data_to_test"></test>';
curl_setopt($ch, CURLOPT_HTTPHEADER, array('POST HTTP/1.1', 'Accept: text/plain', 'Content-length:'.strlen($xmlstream)));
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlstream);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

The content of the $_POST["xml"] variable received is :

_POST["xml"] <?xml version=\"1.0\" encoding=\"UTF-8\"?><test data=\"data_to_test\"></test>

Instead of :

_POST["xml"] <?xml version="1.0" encoding="UTF-8"?><test data="data_to_test"></test>

Any idea ?

Best regards,

Antonio Navarro Navarro
hostmaster <at> bemarnet.es
BemarNet Management
http://www.bemarnet.es
(Continue reading)

Daniel Stenberg | 6 Jul 10:39 2004
Picon

Re: Slashes and quotes

On Tue, 6 Jul 2004, Antonio Navarro Navarro wrote:

> curl_setopt($ch, CURLOPT_HTTPHEADER, array('POST HTTP/1.1', 'Accept: 
> text/plain', 'Content-length:'.strlen($xmlstream)));

1. You can't set the POST request with the CURLOPT_HTTPHEADER option (but it
    is already used since you set CURLOPT_POST and CURLOPT_POSTFIELDS)

2. "Content-length" is set automatically to the strlen of the data unless you
    set it yourself. CURLOPT_POSTFIELDSIZE is the option to use to set the
    post size.

> The content of the $_POST["xml"] variable received is :
>
> _POST["xml"] <?xml version=\"1.0\" encoding=\"UTF-8\"?>

[...]

curl doesn't translate anything, so that is either done by the server or by 
PHP.

--

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html

Thorsten Hamann | 6 Jul 10:52 2004
Picon

Re: Slashes and quotes

Hi Antonio,

I am doing the same thing, I'll just provide my code and you can try 
whether this will work at your end. I don't fiddle around with the headers, 
so maybe there's your showstopper.

I POST XML to an url and get XML back, so I use a function with the XML to 
send as a parameter:

function xml_anfrage($fxml) { // post  XML to URL and return XML from there
	$xmlurl = "http://someserver.com/someurl.asp";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$xmlurl); // URL setzen
	curl_setopt($ch, CURLOPT_FAILONERROR, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 20); // Timeout after 20 secs
	curl_setopt($ch, CURLOPT_POST, 1); // set POST method
	curl_setopt($ch, CURLOPT_POSTFIELDS, $fxml); // data to POST, unencoded
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Put result into variable 
instead of displaying in browser
	$data = curl_exec($ch); // do it
	curl_close($ch);
	return $data;
}

This function would be used like this:

$xml = "<?xml 
version=\"1.0\"?"."><Request><Mandatnummer>".$fhnr."</Mandatnummer></Request>";
$resultxml = xml_anfrage($xml);

(Continue reading)

Stéphane Viaud-Murat | 6 Jul 10:50 2004

RE : Slashes and quotes

Antonio,

You must have magic_quotes_gpc or magic_quotes_runtime activated in your
php.ini
This strips out ' and " characters...

Stephane

-----Message d'origine-----
De : curl-and-php-bounces <at> cool.haxx.se
[mailto:curl-and-php-bounces <at> cool.haxx.se] De la part de Daniel Stenberg
Envoyé : mardi 6 juillet 2004 10:39
À : Antonio Navarro Navarro; using curl with PHP
Objet : Re: Slashes and quotes

On Tue, 6 Jul 2004, Antonio Navarro Navarro wrote:

> curl_setopt($ch, CURLOPT_HTTPHEADER, array('POST HTTP/1.1', 'Accept:
> text/plain', 'Content-length:'.strlen($xmlstream)));

1. You can't set the POST request with the CURLOPT_HTTPHEADER option
(but it
    is already used since you set CURLOPT_POST and CURLOPT_POSTFIELDS)

2. "Content-length" is set automatically to the strlen of the data
unless you
    set it yourself. CURLOPT_POSTFIELDSIZE is the option to use to set
the
    post size.

(Continue reading)

imran khalid | 6 Jul 15:08 2004
Picon

Re: Slashes and quotes

Hi,

Please use the PHP Function stripslashes as:-

$_POST["xml"] =stripslashes( $_POST["xml"] );

Sincerely,
Imran Khalid (PHP CURL Web Developer)
http://www.imrankhalid.5u.com
Email: imranlink <at> hotmail.com
..................................................

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

Paul | 8 Jul 10:07 2004
Picon

php-curl on Debian

Can anyone point me to a newbie instruction on getting php-curl working 
on Debian running php 4.3.4?

TIA,
Paul

Ron Whiteleather | 12 Jul 21:37 2004

ASPX Active Directory Authentication Help

Hi All,

I have an ASPX application that I am able to login to via PHP and
libcURL and the "home" page is returned.  I also believe that it is
passing an active directory cookie used for authentication.  My problem
is that when I try to "navigate" to the next page, I get automatically
redirected to the login page.  I believe this is because I am not
passing the authentication information back properly as part of my
second request but I am not clear on how to do it.

Any help or suggestions would be greatly appreciated.

Ron

Christian Fanzott | 13 Jul 10:12 2004
Picon

curl ssh

is there a possability to check via curl if the ports for ssh are open or not  respectively if i actually have the possability to check whether a port is answering or not with the use of curl?
tia

Gmane