wff_fetchUrl

The Facebook Feed wff fetchUrl function.

Description

wff_fetchUrl( $url ); 

Parameters (1)

0. $url
The url.

Usage

  1. if ( !function_exists( 'wff_fetchUrl' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'facebook-feed/facebook-feed-shortcode.php'; 
  3.  
  4. // The url. 
  5. $url = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wff_fetchUrl($url); 
  9.  

Defined (1)

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

/facebook-feed-shortcode.php  
  1. function wff_fetchUrl($url) 
  2. {  
  3. if(is_callable('curl_init')) { 
  4. $ch = curl_init(); 
  5. curl_setopt($ch, CURLOPT_URL, $url); 
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  7. curl_setopt($ch, CURLOPT_TIMEOUT, 20); 
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
  9. $feedData = curl_exec($ch); 
  10. curl_close($ch); 
  11. //If not then use file_get_contents 
  12. } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) { 
  13. $feedData = @file_get_contents($url); 
  14. //Or else use the WP HTTP AP 
  15. } else { 
  16. if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' ); 
  17. $request = new WP_Http; 
  18. $result = $request->request($url); 
  19. $feedData = $result['body']; 
  20. return $feedData;