Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/02/2015, 21:20
freyes2014
 
Fecha de Ingreso: febrero-2015
Mensajes: 1
Antigüedad: 9 años, 2 meses
Puntos: 0
recibir arreglos y json en php

Hola que tal tengo el siguiente problema:
Necesito recibir arreglos para que sean consumidos en un servicio rest. el envio de la informacion del cliente seria algo asi:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://192.168.0.58/prueba/consumo_arreglos.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \n customer_code: \"C001\",\n products: [\n {code: \"P001\", quantity: 21},\n {code: \"P002\", quantity: 1}\n ]\n}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response = curl_exec($ch);
curl_close($ch);

var_dump($response);
?>

Lo que no se como recibir esa informacion en consumo_arreglos.php
Le he intentado de varias formas entre ellas lo siguiente:

<?php

$datos = $_POST['datos1'];

$postDataArray = json_decode($datos);
echo $postDataArray;
?>

Si le agrego un
print_r($_POST);

No me da nada.

La verdad es que soy novato en PHP y no se como hacerle. Alguien me podria ayudar?