curl-and-php
Re: Curl-and-php Digest, Vol 11, Issue 13
Date: Fri, 24 Dec 2004 02:29:18 +0100
Hi Daniel,
I made some php script that converts curl command line command into php
script and I'm asking you am I making somewhere mistakes and would this
work?
php script look as follow:
<?php
$url = "https://somegetway.company.com"; // URL you want to fetch
$keyfile = "test.key"; // your private key file
$certfile = "test_cert.crt"; // SSL certificate
$capath = "ca.pem"; // password for private key
$ch = curl_init ($url);
if (!$ch) {
die ("Couldn't Initialize cURL handle\n");
}
curl_setopt ($ch, CURLOPT_SSLCERT, $certfile);
curl_setopt ($ch, CURLOPT_SSLKEY, $keyfile);
curl_setopt ($ch, CURLOPT_CAPATH, $capath);
$code = curl_exec ($ch);
if ($code != CURLE_OK) {
die ("cURL error: " . curl_error ($ch) . "\n");
}
curl_close ($ch);
?>
I see in your docs that you're using curl_easy_setopt(); insted of
curl_setopt();
I used this for certificates, ca.pem and a key:
curl_setopt ($ch, CURLOPT_SSLCERT, $certfile);
curl_setopt ($ch, CURLOPT_SSLKEY, $keyfile);
curl_setopt ($ch, CURLOPT_CAPATH, $capath);
Would this php script convert curl command line command:
curl --cert test_pem.crt --key test.key --cacert ca.pem
https://somegetway.company.com
and make work because I could nor use curl command line tool because it's
with hosting company???
Thanks in advance,
Nikolaj
----- Original Message -----
From: <curl-and-php-request_at_cool.haxx.se>
To: <curl-and-php_at_cool.haxx.se>
Sent: Wednesday, December 22, 2004 12:00 PM
Subject: Curl-and-php Digest, Vol 11, Issue 13
> Send Curl-and-php mailing list submissions to
> curl-and-php_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://cool.haxx.se/mailman/listinfo/curl-and-php
> or, via email, send a message with subject or body 'help' to
> curl-and-php-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-and-php-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Curl-and-php digest..."
>
>
> Today's Topics:
>
> 1. PHP CURL : Long wait time for CURL_IPRESOLVE_V6 (Sukhbir Gill)
> 2. Re: PHP CURL : Long wait time for CURL_IPRESOLVE_V6
> (Daniel Stenberg)
> 3. PHP.cURL adn transaction processing? (Nikolaj Popovic)
> 4. Re: PHP.cURL adn transaction processing? (Daniel Stenberg)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 21 Dec 2004 11:08:32 -0700
> From: Sukhbir Gill <sukhbirgs_at_gmail.com>
> Subject: PHP CURL : Long wait time for CURL_IPRESOLVE_V6
> To: curl-and-php_at_cool.haxx.se
> Message-ID: <8933f74904122110083a8e82ae_at_mail.gmail.com>
> Content-Type: text/plain; charset=US-ASCII
>
> I am having problem with CURL_IPRESOLVE_V6. It takes long time to
> resolve the host and then CURL_IPRESOLVE_V4 takes over and it does it
> instantaneously. My system setting are:
>
> PHP Version 4.3.9
> Fedora core 2
> Curl 7.12.1
>
> /***********************************************
> PHP CODE FOR CURL SETUP
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
>
> // next two lines added to make it work on certain servers
> (Apache2 related?)
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
>
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_HTTPHEADER, array("Referer: " .
STORE_NAME,
> "Host: " . $url,
> "Accept:
>
> image/gif,image/jpeg,image/pjpeg,text/plain,text/html,*/*",
> "Pragma:",
> "Content-Type:image/gif
"));
>
> curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
> $xmlResponse = curl_exec ($ch);
> curl_close ($ch);
>
> I tried setting CURLOPT_IPRESOLVE to CURL_IPRESOLVE_V4 but it still
> tries CURL_IPRESOLVE_V6 first.
> *******************************************************************/
>
> This is the info by using curl_getinfo($ch)
> /****************************************************************
>
> Array
> (
> [url] => https://www.ups.com/ups.app/xml/Rate
> [content_type] => application/xml
> [http_code] => 200
> [header_size] => 160
> [request_size] => 1825
> [filetime] => -1
> [ssl_verify_result] => 0
> [redirect_count] => 0
> [total_time] => 34.645003
> [namelookup_time] => 34.293846
> [connect_time] => 34.335259
> [pretransfer_time] => 34.448216
> [size_upload] => 0
> [size_download] => 2458
> [speed_download] => 70
> [speed_upload] => 0
> [download_content_length] => 2458
> [upload_content_length] => 0
> [starttransfer_time] => 34.64493
> [redirect_time] => 0
> )
>
> You can see that [namelookup_time] => 34.293846 is really
> long. And all that time is taken by CURL_IPRESOLVE_V6.
> ****************************************************************/
>
> I am using similar code for getting information from FEDEX website
> "https://gateway.fedex.com/GatewayDC" and it takes some where 0.80 sec
> to 1.10 secods.
>
> My question is "Can i some how dissable CURL_IPRESOLVE_V6 and just use
> CURL_IPRESOLVE_V4. I did tried it in my php code but its not working.
> ".
>
> I really appriciate any help.
> Regards,
> Sukhbir
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 21 Dec 2004 20:52:55 +0100 (CET)
> From: Daniel Stenberg <daniel-curl_at_haxx.se>
> Subject: Re: PHP CURL : Long wait time for CURL_IPRESOLVE_V6
> To: Sukhbir Gill <sukhbirgs_at_gmail.com>, Programming PHP/CURL
> <curl-and-php_at_cool.haxx.se>
> Message-ID: <Pine.LNX.4.61.0412212048040.4741_at_yvahk3.pbagnpgbe.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Tue, 21 Dec 2004, Sukhbir Gill wrote:
>
> > I am having problem with CURL_IPRESOLVE_V6. It takes long time to
resolve
> > the host and then CURL_IPRESOLVE_V4 takes over and it does it
> > instantaneously.
>
> "CURL_IPRESOLVE_V4 takes over" ?
>
> Besides, the resolving is all done by getaddrinfo() (unless you built with
> c-ares) and I fail to see how libcurl can make that go any faster or
slower
> than what your system and network config makes it.
>
> > I tried setting CURLOPT_IPRESOLVE to CURL_IPRESOLVE_V4 but it still
tries
> > CURL_IPRESOLVE_V6 first.
>
> How do you know this?
>
> > My question is "Can i some how dissable CURL_IPRESOLVE_V6 and just use
> > CURL_IPRESOLVE_V4."
>
> You mean "can I disable IPv6 name resolving and just use IPv4?". The
option
> names you keep referring to is how to alter the behaviour run-time, and
you
> already said you did this and you claim it makes no difference.
>
> The answer is: yes - just build curl with "configure --disable-ipv6".
>
> --
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 22 Dec 2004 03:37:44 +0100
> From: "Nikolaj Popovic" <nikolajpop_at_yubc.net>
> Subject: PHP.cURL adn transaction processing?
> To: <curl-and-php_at_cool.haxx.se>
> Message-ID: <00d001c4e7cf$383f1000$a4a97cd4_at_perpetuum>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> I received the PHP modules from a getaway company that uses cURL as a
method for sending form details to the getaway system. I contacted the
developer from this getaway company and he sent me some explanation. I'm new
with cURL and have some question! The developer sent to me this:
>
> " First thing you should do is to check connectivity with our server using
cURL, like:
>
> curl --cert test_pem.crt --key test.key --cacert ca.pem
https://somegetway.company.com "
>
>
>
> A question is: How can I check connectivity with their server?
>
>
>
> Do I need to write a PHP script that can check the connectivity? Could you
give me some example of this - php script that checks this connectivity?
>
>
>
> I found some tutorials that explains exec() PHP function or poped ()
function regarding to this but I'm not sure how should I write a PHP script
that checks the connectivity!
>
>
>
> I'll appreciate any help from you. Thank you in advance.
>
>
>
> Nikolaj
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
http://cool.haxx.se/pipermail/curl-and-php/attachments/20041222/56b3121b/att
achment.html
>
> ------------------------------
>
> Message: 4
> Date: Wed, 22 Dec 2004 10:30:51 +0100 (CET)
> From: Daniel Stenberg <daniel-curl_at_haxx.se>
> Subject: Re: PHP.cURL adn transaction processing?
> To: Programming PHP/CURL <curl-and-php_at_cool.haxx.se>
> Message-ID: <Pine.LNX.4.61.0412221029110.27786_at_yvahk3.pbagnpgbe.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Wed, 22 Dec 2004, Nikolaj Popovic wrote:
>
> > " First thing you should do is to check connectivity with our server
using
> > cURL, like:
> >
> > curl --cert test_pem.crt --key test.key --cacert ca.pem
> > https://somegetway.company.com "
> >
> > A question is: How can I check connectivity with their server?
>
> Using that command line, I guess he means that if it returns HTML fine,
you
> have "connectivity".
>
> > Do I need to write a PHP script that can check the connectivity?
>
> Don't ask us. That's your job to find out.
>
> > Could you give me some example of this - php script that checks this
> > connectivity?
>
> Read the docs and convert that command line to curl-functions instead.
> Shouldn't be hard. Ask here if you get stuck.
>
> --
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
>
> ------------------------------
>
> _______________________________________________
> Curl-and-php mailing list
> Curl-and-php_at_cool.haxx.se
> http://cool.haxx.se/mailman/listinfo/curl-and-php
>
>
> End of Curl-and-php Digest, Vol 11, Issue 13
> ********************************************
>
>
Received on 2004-12-24