代码:
<?
require_once 'includes/unirest/Unirest.php';
$cpf = "MY CPF";
$response = Unirest\Request::get("https://consulta-situacao-cpf-cnpj.p.mashape.com/consultaSituacaoCPF?cpf=".$cpf,
array(
"X-Mashape-Key" => "MY SECRET KEY"
)
);
echo $response->raw_body;
?>
结果:
{"nome":"MY NAME","situacaoCadastral":"CPF STATUS"}
但是,我如何设置特定值('nome')到变量?
像这样:
MY NAME
答案 0 :(得分:0)
试试这个
$getResponseVal = $response->raw_body;
$getDecodeData = json_decode($getResponseVal);
$getSpecificValue = $getSpecificValue['nome']; //this will assign nome value to variable