Good afternoon. I'm trying to get a value from a page (.asp) after giving cURL in it.
My code:
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.minhaapi.com.br/script_session.asp?file=api.asp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CUSTOMREQUEST => "GET",
));
$token = curl_exec($curl);
Response cURL:
session={id:7444326,hash:'{2B71B3FB-8FAE-4C7E-BFCF-C9F0EE71D3E3}',customer:{id:8901,name:'cliente1',email:'[email protected]',groupid:0},cart: ...
Since the value of the first id, and the hash changes to each curl, how can I get these two values and save them in a variable? I have already tried the getStr function and did not succeed. Thanks.
Unsuccessful attempt:
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.minhaapi.com.br/script_session.asp?file=api.asp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CUSTOMREQUEST => "GET",
));
$token = curl_exec($curl);
$retorno = ltrim($retorno, 'session={');
$retorno = rtrim($retorno, '};');
$retorno = json_decode($token, true);
$id = $retorno['id'];
$hash = $retorno['hash'];
$customer = $retorno['customer'];
echo $hash;