HttpRequestService::call_fopen PHP Method

call_fopen() public method

public call_fopen ( $url, $method, $postFields = null, $username = null, $password = null, $contentType = null )
    public function call_fopen($url, $method, $postFields = null, $username = null, $password = null, $contentType = null)
    {
        if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0 && !empty($this->format)) {
            $url = "{$this->api_url}{$url}.{$this->format}";
        }
        $this->http_url = $url;
        $this->contentType = $contentType;
        $this->postFields = $postFields;
        $url = in_array($method, self::$paramsOnUrlMethod) ? $this->to_url() : $this->get_http_url();
        $params = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n", 'content' => $this->create_post_body($this->postFields)));
        $ctx = stream_context_create($params);
        $fp = fopen($url, 'rb', false, $ctx);
        if (!$fp) {
            die('can not open server!');
        }
        $response = @stream_get_contents($fp);
        if ($response === false) {
            die('can not get message form server!');
            //throw new Exception("Problem reading data from {$url}, {$php_errormsg}");
        }
        return $response;
    }