jeudi 13 juin 2019

Laravel 5.8 rest client how to save api token in the .env

I should like to insert the return token from api into the .env in when after i want pass it header in

    class GuzzleController extends Controller
    {
    public function getToken()
    {
        $client = new Client();
        $request = $client->request('POST', 'http://192.168.53.27:1996/api/login/',
            [
                    'form_params' => [
                    'user_name' => 'userName',
                    'password' => 'Passs',
                ]
            ]);
        return json_decode((string)$request->getBody(), true);

    }
}




via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire