note 89850 added to function.curl-setopt
| From: | maran dot emil at gmail dot com | Date: | Wed, 25 Mar 2009 19:54:16 +0000 |
| Subject: | note 89850 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152449@lists.php.net to get a copy of this message | ||
In case that you need to read SSL page content from https with curl, this function can help you:
<?
function get_web_page( $url,$curl_data )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => 1, // i am sending post data
CURLOPT_POSTFIELDS => $curl_data, // this are my post vars
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
CURLOPT_SSL_VERIFYPEER => false, //
CURLOPT_VERBOSE => 1 //
);
$ch = curl_init($url);
curl_setopt_array($ch,$options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch) ;
$header = curl_getinfo($ch);
curl_close($ch);
// $header['errno'] = $err;
// $header['errmsg'] = $errmsg;
// $header['content'] = $content;
return $header;
}
$curl_data = "var1=60&var2=test";
$url = "https://www.yourdomain.com";
$response = get_web_page($url,$curl_data);
print '<pre>';
print_r($response);
?>
----
Server IP: 212.124.37.9
Probable Submitter: 85.180.38.193
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/89850
Del: integrated -- https://master.php.net/note/delete/89850/integrated
Del: useless -- https://master.php.net/note/delete/89850/useless
Del: bad code -- https://master.php.net/note/delete/89850/bad+code
Del: spam -- https://master.php.net/note/delete/89850/spam
Del: non-english -- https://master.php.net/note/delete/89850/non-english
Del: in docs -- https://master.php.net/note/delete/89850/in+docs
Del: other reasons-- https://master.php.net/note/delete/89850
Reject -- https://master.php.net/note/reject/89850
Search -- https://master.php.net/manage/user-notes.php