json데이타가 정상적으로 보내졌는지 확인하려합니다. (curl post json 전송)

json데이타가 정상적으로 보내졌는지 확인하려합니다. (curl post json 전송)

QA

json데이타가 정상적으로 보내졌는지 확인하려합니다. (curl post json 전송)

답변 1

본문

<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

테스트로 일단

본인의 url을 적고 파일만들고 테스트 하시면 되겠습니다.

본인 url 이 aaa.com이면

aaa.com에 test.php 만드시고

http://aaa.co.kr/getJsondata.php 이부분을 $url = G5_URL."/test.php";

하시고 테스트 끝나면 보내야할 url로 수정하시면 되겠네요

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 129,111
© SIRSOFT
현재 페이지 제일 처음으로