How to connect to a WEb Service Rest

0

Good morning. I have to connect to a Web Service Rest to validate CURP with php, I have the url, the username and password of the WS but I have not been able to find the way in which I must connect, I attach the form in which I must send the data to be able to Verify, I hope you can support me since I am new to this and I do not know anything, I already look for and I can not find much how to connect, send data and receive, they would support me enough orienting me how to connect and from there to be able to send tests and data reception

    
asked by Israel Gutierrez 01.12.2017 в 18:04
source

1 answer

1

What you must do is the first .. from your controller you must use the php function called file, this is responsible for running that webservice and bring the result .. as yours brings a json array you must do the following procedure.

    $array_json = file('https://api.plataforma.ipn.mx/publico/general/secure/renapo/curp/consultar');

Once the webservice has been obtained in the variable, what is next to be done is to use one more function to decompose this json array and remain as a normal array.

    $array_normal = json_decode($array_json[0],true);

If you want to get a value from that array you use the array_column () function like this:

    $extraer_columna = array_column($array_normal , 'CURP');

and then

    $curp = $extraer_columna[0];
    
answered by 01.12.2017 в 20:52