我在测试这个。这是我第一次使用unirest和mashape。
代码:
<?
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发布于 2017-01-28 13:54:57
尝尝这个
$getResponseVal = $response->raw_body;
$getDecodeData = json_decode($getResponseVal);
$getSpecificValue = $getSpecificValue['nome']; //this will assign nome value to variablehttps://stackoverflow.com/questions/41906779
复制相似问题