mardi 30 mai 2017

Laravel Guzzle params

I have this curl request from the API docs

curl http://ift.tt/2sbeOir --user TOKAN-HO:2eL4aKsSGCaN4FH8 -k

Now I'm trying to call this request with Laravel 5.1 using Guzzle library, so I do this

public function testacorne()
{
    $client = new GuzzleHttp\Client();

    $res = $client->get('http://ift.tt/2rBDMuq', [
        'form_params' => [
            'user' => 'TOKAN-HO:2eL4aKsSGCaN4FH8'
        ]
    ]);

    dd($res);
}

This is what i get

ClientException in RequestException.php line 107:
Client error: `GET http://ift.tt/2rBDMuq` resulted in a `401 Unauthorized` response:
{
"Message": "Authorization has been denied for this request."
}

But the username and password are correct. How can I fix this issue?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire