|
Comments for: ian_gilfillan20050525
| Message # 1510092: |
|
Date: 06/28/07 21:58
By: Bob Subject: Curl & php 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@21stcenturycompany.com phone: (888) 961-6677 fax: (805) 964-5007 |
Previous Message | Next Message |
| Comments: | ||
| Thanks | josh | 03/09/09 02:11 |
| RE: A simple cURL script to look up the meani | Good Tutorial | 10/01/07 12:55 |
| Curl & php | Bob | 06/28/07 21:58 |
| Great Tutorial | Kerry | 05/09/07 17:18 |
| info needed on CURLOPT_SSL_VERIFYPEER | indu | 11/04/05 00:54 |
| A simple cURL script to look up the meaning o | Muchacho | 06/14/05 12:53 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


