umm, assuming the calls come from a request, where are you storing the $token.
I don't see any reference to session.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to make 2 api calls at the same time, the first gets a token and the second brings the user data.
The problem is that when i pass the token on the second api call it gives me a session expired.
$client = new Client([
'base_uri' => 'https://portaldoagente.com.br/WCF/wcfTravellink/Loja.svc/',
'headers' => [
'Content-Type' => 'application/json'
]
]);
First call:
$response = $client->post('Autenticar',
['body' => json_encode(
[
'login' => 'example',
'senha' => 'example'
]
)],
);
$body = $response->getBody()->getContents();
$responseXml = simplexml_load_string($body);
$token = $responseXml->children;
Second call
$response = $client->post('ConsultarCliente',
['body' => json_encode(
[
'token'=> $token,
'ClienteLogin' => [
'Login' => 'example',
'Senha' => 'example'
]
]
)]
);
$Consulta = $response->getBody()->getContents();
The token needed to stay in the session so it would not expire? When I try this in postman it works fine, first I make a call to the first method to get the token, then I make another call to the second method passing the token.
Please or to participate in this conversation.