**以后我想在一个视图中得到结果,我通过IDCEDULA搜索得到名称和IDCEDULA
不知道为什么标记错误**
这是API
{
"items": [
{
"anioreg": 1991,
"carArea": null,
"carCons": null,
"carNivel": null,
"carSarea": null,
"curp": null,
"desins": "UNIVERSIDAD PANAMERICANA",
"foja": null,
"idCedula": "1629426",
"inscons": 251,
"insedo": 9,
"libro": null,
"materno": "NIETO",
"maternoM": null,
"nombre": "ENRIQUE",
"nombreM": null,
"numero": null,
"paterno": "PEÑA",
"paternoM": null,
"sexo": "1",
"tipo": "C1",
"titulo": "LICENCIATURA EN DERECHO"
}
],
"filename": null,
"idCedula": null,
"idProfesionista": null,
"sessionId": null,
"theStream": null,
"token": null,
"urlVideo": null
}
这是我通过GUZZLEHTTP获取API URL的控制器我已经尝试过json编码,但它仍然不工作**
public function index()
{
$client = new Client([
'base_uri' => 'https://www.cedulaprofesional.sep.gob.mx/',
'timeout' => 300,
'Content-Type: application/vnd.api+json',
'Accept: application/vnd.api+json',
]);
$response = $client->request('GET',
"https://www.cedulaprofesional.sep.gob.mx/cedula/buscaCedulaJson.action?json=%7B%22maxResult%22%3A%2250%22%2C%22nombre%22%3A%22%27%20LUIS%20%27%22%2C%22paterno%22%3A%22%27%20HERNANDEZ%20%27%22%2C%22materno%22%3A%22%27%20GRANILLO%20%27%22%2C%22idCedula%22%3A%22%22%7D&wt=json");
$responseData = json_decode($response->getBody()->getContents(), true);
return ($responseData);
您最常用的是POST方法,而不是GET方法
编辑1
这是我的JavaScript解决方案与Axios
const axios = require("axios");
const cedula = 1629426
const result = axios({
method: "POST",
url: `https://www.cedulaprofesional.sep.gob.mx/cedula/buscaCedulaJson.action?json={"maxResult":"1","nombre":"","paterno":"","materno":"","idCedula":"${cedula || ""}"}`,
headers: {"Content-Type": "application/json"},
}).then((res) => JSON.parse(res.data))