Skip to content

Instantly share code, notes, and snippets.

@byronhe byronhe/https_client.php
Last active Dec 29, 2015

What would you like to do?
https client
// Initialize session and set URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_FALSESTART, 1);
curl_setopt($ch, CURLOPT_SSL_ENABLE_ALPN, 1);
// CURLOPT_CAINFO is auto detected,see
// Get the response and close the channel.
$response = curl_exec($ch);
echo $response;
echo "GET ",$url," failed.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.