getAuthString example

$hooks->register('curl.before_send', [$this, 'curl_before_send']);
        $hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']);
    }

    /** * Set cURL parameters before the data is sent * * @param resource|\CurlHandle $handle cURL handle */
    public function curl_before_send(&$handle) {
        curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString());
    }

    /** * Add extra headers to the request before sending * * @param string $out HTTP header string */
    public function fsockopen_header(&$out) {
        $out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString()));
    }

    
Home | Imprint | This part of the site doesn't use cookies.