Recipe 11.6 Fetching an HTTPS URL
11.6.1 Problem
You want to
retrieve a secure URL.
11.6.2 Solution
Use the cURL extension with an HTTPS
URL:
$c = curl_init('https://secure.example.com/accountbalance.php');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$page = curl_exec($c);
curl_close($c);
11.6.3 Discussion
To retrieve secure URLs, the cURL extension needs access to an
SSL library, such as
OpenSSL.
This library must be available when PHP and the cURL extension are
built. Aside from this additional library requirement, cURL treats
secure URLs just like regular ones. You can provide the same cURL
options to secure requests, such as changing the request method or
adding POST data.
11.6.4 See Also
The
OpenSSL Project at
http://www.openssl.org/.
|