private function fopenRequest($get_variables=null, $post_variables=null, $headers=null) {
    $http_options = array('method'=>'GET', 'timeout'=>3);

    $string_headers = '';
    if (is_array($headers)) {
      foreach ($headers as $key => $value) {
        $string_headers .= "$key: $value\r\n";
      }
    }

    if (is_array($get_variables)) {
      $get_variables = '?' . str_replace('&amp;', '&', urldecode(http_build_query($get_variables, '', '&')));
    }
    else {
      $get_variables = null;
    }

    if (is_array($post_variables)) {
      $post_variables = str_replace('&amp;', '&', urldecode(http_build_query($post_variables, '', '&')));
      $http_options['method'] = 'POST';
      $string_headers = "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($post_variables) . "\r\n" . $string_headers;
      $http_options['header'] = $string_headers;
      $http_options['content'] = $post_variables;
    }
    else {
      $post_variables = '';
      $http_options['header'] = $string_headers;
    }

    $context = stream_context_create(array('http'=>$http_options));
    $response = @file_get_contents($this->url . $get_variables, null, $context);

    return array('body'=>$response!==false?$response:'Request failed, consider using php5-curl module for more information.', 'code'=>$response!==false?'200':'400');
  }
private function fopenRequest($get_variables=null, $post_variables=null, $headers=null) {
    $http_options = array('method'=>'GET', 'timeout'=>3);

    $string_headers = '';
    if (is_array($headers)) {
      foreach ($headers as $key => $value) {
        $string_headers .= "$key: $value\r\n";
      }
    }

    if (is_array($get_variables)) {
      $get_variables = '?' . str_replace('&amp;', '&', urldecode(http_build_query($get_variables, '', '&')));
    }
    else {
      $get_variables = null;
    }

    if (is_array($post_variables)) {
      $post_variables = str_replace('&amp;', '&', urldecode(http_build_query($post_variables, '', '&')));
      $http_options['method'] = 'POST';
      $string_headers = "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($post_variables) . "\r\n" . $string_headers;
      $http_options['header'] = $string_headers;
      $http_options['content'] = $post_variables;
    }
    else {
      $post_variables = '';
      $http_options['header'] = $string_headers;
    }

    $context = stream_context_create(array('http'=>$http_options));
    $response = @file_get_contents($this->url . $get_variables, null, $context);

    return array('body'=>$response!==false?$response:'Request failed, consider using php5-curl module for more information.', 'code'=>$response!==false?'200':'400');
  }
private function fopenRequest ( $ get_variables = null , $ post_variables = null , $ headers = null ) { $ http_options = array ( 'method' => 'GET' , 'timeout' => 3 ) ; $ string_headers = '' ; if ( is_array ( $ headers ) ) { foreach ( $ headers as $ key => $ value ) { $ string_headers .= "$key: $value\r\n" ; } } if ( is_array ( $ get_variables ) ) { $ get_variables = '?' . str_replace ( '&amp;' , '&' , urldecode ( http_build_query ( $ get_variables , '' , '&' ) ) ) ; } else { $ get_variables = null ; } if ( is_array ( $ post_variables ) ) { $ post_variables = str_replace ( '&amp;' , '&' , urldecode ( http_build_query ( $ post_variables , '' , '&' ) ) ) ; $ http_options [ 'method' ] = 'POST' ; $ string_headers = "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen ( $ post_variables ) . "\r\n" . $ string_headers ; $ http_options [ 'header' ] = $ string_headers ; $ http_options [ 'content' ] = $ post_variables ; } else { $ post_variables = '' ; $ http_options [ 'header' ] = $ string_headers ; } $ context = stream_context_create ( array ( 'http' => $ http_options ) ) ; $ response = @ file_get_contents ( $ this -> url . $ get_variables , null , $ context ) ; return array ( 'body' => $ response !== false ? $ response : 'Request failed, consider using php5-curl module for more information.' , 'code' => $ response !== false ? '200' : '400' ) ; }
HTTP request using native PHP fopen function
Requires PHP openSSL

@param Array $get_variables
@param Array $post_variables
@param Array $headers
HTTP request using native PHP fopen function Requires PHP openSSL