json데이타가 정상적으로 보내졌는지 확인하려합니다. (curl post json 전송)
<form action="jsonSend.php"... /form>에서 submit으로 전송을 하였고
jsonSend.php
<?php
$jsonInfo = array(
'resut' =>'true',
'name' =>$name,
'phone' =>$phone
);
$ch = curl_init(); // Initiate cURL
$jsonData = json_encode($jsonInfo, JSON_UNESCAPED_UNICODE);
$url = "http://aaa.co.kr/getJsondata.php"; // Where you want to URL 가칭
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // httpheader json
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true); // Tell cURL you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); // // Define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the output in string format
$output = curl_exec ($ch); // Execute
curl_close ($ch); // Close cURL handle
?>
반대측 시스템 ( aaa.co.kr )에서 아래와 같이 하면 json 들어온 값을 확인하는 결과는 ???
$getJsondata = file_get_contents ('php://input') ;//JSON 문자열을 연관배열로 전환
이렇게 처리한다고 하는데요...
여러개가 전달될 수 있으므로
받는 쪽에서는 실시간으로 json값이 누락되지 않고 처리해야 할텐데 ...
어떻께 처리되는것인지...
답변 1개 / 댓글 2개
테스트로 일단
본인의 url을 적고 파일만들고 테스트 하시면 되겠습니다.
본인 url 이 aaa.com이면
aaa.com에 test.php 만드시고
http://aaa.co.kr/getJsondata.php 이부분을 $url = G5_URL."/test.php";
하시고 테스트 끝나면 보내야할 url로 수정하시면 되겠네요
답변에 대한 댓글 2개
그래서 받는 페이지에서는 그냥 보여주는게 아니고
db에 차곡차곡 저장을 해야겠지요
답변을 작성하려면 로그인이 필요합니다.
여러명이 json 포맷으로 동시에 보냈다면,
그중 마지막것만 남아 있는거 아닌지??
어떻게 처리되는지 잘 몰라서~~