Fórum Como usar variaveis num POSTFIELD? #618648
30/08/2022
0
Já pensei em tudo, oq na minha cabeça funciona, no código não ksksks, mas como eu faço pra colocar variaveis no CURLOPT_POSTFIELD?
e o raio da API exige receber nesse formato json, talvez com um json_encode? mas não tenho ideia de como faria.
até o momento tá assim, eu teria que inserir variaveis nos campos "cpf" "taxa" "tabela" as datas e os valores tbm
segue o código:
e o raio da API exige receber nesse formato json, talvez com um json_encode? mas não tenho ideia de como faria.
até o momento tá assim, eu teria que inserir variaveis nos campos "cpf" "taxa" "tabela" as datas e os valores tbm
segue o código:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://pririrpaoduro-financeira.com.br/sim/calculo',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"cpf" : "00000000000",
"taxa" : 2.04,
"tabela" : 38776,
"parcelas" : [
{
"dataRepasse_1": "01/08/2023",
"valor_1": 42.15
},
{
"dataRepasse_2": "01/08/2024",
"valor_2": 21.08
},
{
"dataRepasse_3": "01/08/2025",
"valor_3": 10.54
},
{
"dataRepasse_4": "01/08/2026",
"valor_4": 5.27
},
{
"dataRepasse_5": "01/08/2027",
"valor_5": 2.63
},
{
"dataRepasse_6": "01/08/2028",
"valor_6": 1.32
},
{
"dataRepasse_7": "01/08/2029",
"valor_7": 0.66
},
{
"dataRepasse_8": "01/08/2030",
"valor_8": 0.33
},
{
"dataRepasse_9": "01/08/2031",
"valor_9": 0.16
},
{
"dataRepasse_10": "01/08/2032",
"valor_10": 0.08
},
{
"dataRepasse_11": "01/08/2033",
"valor_11": 0.04
},
{
"dataRepasse_12": "01/08/2034",
"valor_12": 0.02
}
]
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '. $bearer, 'Content-Type: application/json'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Leonardo Souza
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)