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

curl-and-php

Curl and php

From: <tfc_at_21stcenturycompany.com>
Date: Thu, 28 Jun 2007 19:55:57 -0700

I am wondering how to do both a post and get request with curl
in the same session.

I need to post the user id and password to https:// url#1
and then get the XML data from https://url#2

I am able to perform the post successfully but get and invalid session
response on the get request.

// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'https:// url ');
curl_setopt($ch, CUPROPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CUPROPT_SSL_VERIFYHOST, FALSE);

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'userid=fieldvalue1&password=fieldvalue2');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (LOGIN)
$postresponse = curl_exec ($ch);
echo $postresponse

// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'https:// url#2 for xml data');

// EXECUTE 2nd REQUEST (xml response)
$getresponse = curl_exec ($ch);
echo $getresponse;

// CLOSE THE SESSION
curl_close($ch);

Bob
Twenty-First Century
website: http://www.21stcenturycompany.com
email: tfc_at_21stcenturycompany.com
phone: (888) 961-6677
fax: (805) 964-5007

Twenty-First Century
website: http://www.21stcenturycompany.com
email: tfc_at_21stcenturycompany.com
phone: (888) 961-6677
fax: (805) 964-5007

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-06-29