fn_get_urlcontent

Get the content of the provided URL.

Description

(string) fn_get_urlcontent( $url ); 

Returns (string)

Parameters (1)

0. $url
The url.

Usage

  1. if ( !function_exists( 'fn_get_urlcontent' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-payment-gateway-for-saferpay/fn-saferpay.php'; 
  3.  
  4. // The url. 
  5. $url = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = fn_get_urlcontent($url); 
  9.  

Defined (1)

The function is defined in the following location(s).

/fn-saferpay.php  
  1. function fn_get_urlcontent($url) { 
  2.  
  3. $ch = curl_init(); 
  4.  
  5. curl_setopt($ch, CURLOPT_URL, $url); 
  6. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 
  7. curl_setopt($ch, CURLOPT_FAILONERROR, true); 
  8. curl_setopt($ch, CURLOPT_HEADER, false); 
  9. curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
  10. curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  12. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);  
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
  15.  
  16. $result = curl_exec($ch); 
  17. $errorString = curl_error($ch); 
  18. $errorNumber = curl_errno($ch); 
  19.  
  20. curl_close($ch); 
  21.  
  22. if ($errorNumber != 0) { 
  23. if (!empty($errorString)) { 
  24.  
  25. throw new Exception($errorString); 
  26.  
  27. } else { 
  28. throw new Exception('CURL download failed'); 
  29.  
  30. return $result;