Questions to implement a webservice

5

I have a question regarding the implementation of a webservice, see the logic:

I have a process that fetches data from multiple users on a system (system A), and I want to get this data and send it to another system (system B), in both cases systems are written in PHP. p>

In this way I have the following script to fetch the user data from system A

export.php file

    <?php
//busca os dados do banco do sistema A   

$r = mysqli_fetch_array($q);

//API Url
$url = 'migracao/import_usuario.php';

//Initiate cURL.
$ch = curl_init($url);

$jsonData = json_encode($r);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($jsonData ))
);

$result = curl_exec($ch);

In my other file, already in system B, called import_user.php I wanted to receive the data passed through CURL to use it in a data insertion method.

file import_user.php is

<?php

new Usuario($usuario); // No caso a variável $usuario seria os dados recebidos atraves CURL

The curl is calling the page correctly, because if it gives a print in import_usuario.php it is printed normally

Debt is like receiving data passed through the php curl

    
asked by anonymous 03.05.2016 / 21:45

1 answer

1

The solution implemented was that the andre informed by the following link:

WebService Remote REST in PHP receiving JSON via POST with problems

    
31.05.2016 / 15:44