[Resolvido] Somar dados recuperados de uma API
Oi, tenho uma dúvida para avançar em uma API.
Preciso somar os valores de todos os endereços exibidos nela. No total deste exemplo tenho 2,484 endereços. A API me deixa exibir no máximo 200 por página
Como exibir total de valores considerando todos endereços
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trongrid.io/v1/contracts/TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq/tokens?only_confirmed=true&only_unconfirmed=true&order_by=balance,desc&limit=200",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}Discussão (15)
Carregando comentários...