Dekodowanie PHP JSON POST [zamknięte]
Próbuję odebraćPOST
dane w postaci JSON. Zwijam to jako:
curl -v --header 'content-type:application/json' -X POST --data '{"content":"test content","friends":[\"38383\",\"38282\",\"38389\"],"newFriends":0,"expires":"5-20-2013","region":"35-28"}' http://testserver.com/wg/create.php?action=post
Po stronie PHP mój kod to:
$data = json_decode(file_get_contents('php://input'));
$content = $data->{'content'};
$friends = $data->{'friends'}; // JSON array of FB IDs
$newFriends = $data->{'newFriends'};
$expires = $data->{'expires'};
$region = $data->{'region'};
Ale nawet kiedy japrint_r ( $data)
nic mi nie wróci. Czy to właściwy sposób przetwarzaniaPOST
bez formularza?