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

curl-and-php

Re: Need to pull header fields out of https post reply

From: Martin Turner <mturner582_at_hotmail.com>
Date: Thu, 21 Nov 2002 14:21:42 -0800

Jermoe suggested the following code:

If you want to get the header field content, use CURLOPT_HEADER as follows:

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,
"https://secure.authorize.net/gateway/transact.dll");
curl_setopt ($ch, CURLOPT_HEADER, 1);
ob_start();
curl_exec($ch);
$string = ob_get_contents();
ob_end_clean();
curl_close($ch);

You get in $string the header field content and the response from the
server. Then you just have to extract the information
that you need with strpos and substr, or preg_match_all.

Hope this helps.

===========================================================

It works for a non-SSL site. But with the site I listed above,
I get nothing back from the SSL site. From a browser, I do get back a body
saying invalid username,password but from within my php script, nothing
comes back. I noticed that the web server I am running from is using libcurl
7.8 with Redhat 7.2 and openssl 0.9.6b. So is the only problem that my web
server needs to be updated to libcurl 7.10.2? What is the minimum version of
libcurl needed to do https??

>From: "Martin Turner" <mturner582_at_hotmail.com>
>Reply-To: curl-and-php_at_lists.sourceforge.net
>To: curl-and-php_at_lists.sourceforge.net
>CC: mturner582_at_hotmail.com
>Subject: Need to pull header fields out of https post reply
>Date: Thu, 21 Nov 2002 01:23:59 -0800
>
>I am trying to write the cURL code to connect to Authorize.Net's SSL
>gateway. I think I have got the first part under control. In my php script
>on my web server, I used the code fragment:
>
>$ch = curl_init();
>curl_setopt($ch, CURLOPT_URL,
>"https://secure.authorize.net/gateway/transact.dll");
>curl_exec($ch);
>curl_close($ch);
>
>I did have a few more lines to open/create a file on my web server and
>write the response into there, but that was causing errors when the
>web server tried to write out many image files that didn't exist on my
>machine. This is a win32 platform with write access to that dir. So
>I removed that portion from the script.
>
>What I want to do is read the header field contents that come back, parse
>certain fields, and then prepare my html response for the client browser.
>Is there an easy way to do this? Any code examples would be appreciated. I
>am a newcomer to php and cURL.
>
>Thanks.
>
>_________________________________________________________________
>MSN 8 with e-mail virus protection service: 2 months FREE*
>http://join.msn.com/?page=features/virus
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-21