Skip to main content
added 462 characters in body
Source Link
miken32
  • 42.5k
  • 16
  • 127
  • 177

Note: The solution in this answer has very significant security implications. Disabling verification potentially permits a MITM attacker to use an invalid certificate to eavesdrop on the requests. Do not follow this solution unless you know exactly what the legal/security implications are and if, for some reason, you are unable to spend 2 minutes properly configuring your system.

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 

Note: The solution in this answer has very significant security implications. Disabling verification potentially permits a MITM attacker to use an invalid certificate to eavesdrop on the requests. Do not follow this solution unless you know exactly what the legal/security implications are and if, for some reason, you are unable to spend 2 minutes properly configuring your system.

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 
Add HTML syntax highlighting
Source Link
Benjamin Loison
  • 5.8k
  • 4
  • 20
  • 37

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 
<!doctype html> <html> <head> <title>Example Domain</title> ... 

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ... 
Source Link
Martin
  • 7.1k
  • 10
  • 47
  • 65

At first you need to have enabled curl extension in PHP. Then you can use this function:

function file_get_contents_ssl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec. curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec. $result = curl_exec($ch); curl_close($ch); return $result; } 

It works similar to function file_get_contents(..).

Example:

echo file_get_contents_ssl("https://www.example.com/"); 

Output:

<!doctype html> <html> <head> <title>Example Domain</title> ...