mardi 22 février 2022

Get responses from External API after login

I want to get data from External API. but, I must login to get session before Getting data and I must Logout after get data

this is my code

    use GuzzleHttp\Client;

    $client = new Client();
    $res = $client->request('POST', 'Login_URL', [
        'json' => [
            "JSON param"
        ]
    ]);
    $res = $client->request('GET', 'Get_URL');
    $res = $client->request('POST', 'Logout_URL');

but I can only the first step (Login). and I getting error message in the second step to get data

Client error: `GET "Get_URL" ` resulted in a `401 Unauthorized` response:{"message":"You are not logged in."}

how I can run all this code with login session on first step ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire