linslin / Yii2-Curl

:curly_loop: Yii2 Curl extension based on PHP cURL.
178 stars 92 forks source link

set param - "--anyauth" #85

Closed DesRodman closed 4 years ago

DesRodman commented 4 years ago

Hello team I'm making next curl request in cmd curl -i -H "Accept: application/json" -H "Content-Type: application/json" --anyauth -u login:pass http://127.0.0.1/api/request

but how can i send such request with your extension?

Thanks

linslin commented 4 years ago

Simply add the Authorization header to your request:

// POST with special headers
$curl = new curl\Curl();
$response = $curl->setHeaders([
        'Accept' => 'application/json',
        'Authorization' => 'Basic '. base64_encode("login:pass")
     ])
     ->get('http://127.0.0.1/api/request');
DesRodman commented 4 years ago

Cool news. But its not working(