Skip to content

Instantly share code, notes, and snippets.

@byronhe
Last active December 29, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byronhe/1c127960168b1f8bd172 to your computer and use it in GitHub Desktop.
Save byronhe/1c127960168b1f8bd172 to your computer and use it in GitHub Desktop.
https client
<?php
$url="https://weixin.qq.com";
$url="https://www.alipay.com";
$url="https://www.baidu.com";
// 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 http://docs.guzzlephp.org/en/latest/request-options.html#verify
// https://github.com/dropbox/dropbox-sdk-php/blob/master/lib/Dropbox/Curl.php
for($i=0;$i<10;++$i){
// Get the response and close the channel.
$response = curl_exec($ch);
if($response){
echo $response;
}else{
echo "GET ",$url," failed.\n";
}
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment