Snippet Information
Version: 0 (latest)
Author: jeff
Language: php
Licensed under MIT
Other versions
v.0 27 Sep (production)
Snippets included by
curl_https_function v.0
None
Snippets that include
curl_https_function v.0
"curl_https_function" v.0 (latest)
Description
easy curl function for https/ssl pages
Run
| View code [+] |
Create a snippet based on this »
<?php
function curl($url)
{
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PORT, 80); //Set the port number
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
return curl_exec($ch);
}
?>

Comments (0) | View comments for all versions (0)
Log in if you have a Kogbox account.