curl 전송시 한글깨짐 문제.. 채택완료
</p>
<p>function get_test_curl($data){</p>
<p>
global $g5, $config;</p>
<p>
$data = json_encode($data);
$method = "POST";
$url = '<a href="https://받는url';" target="_blank" rel="noopener noreferrer">https://받는url';</a>
$headers = array(
"content-type: application/json;charset=UTF-8",
"accept-encoding: gzip"
); </p>
<p> $ch = curl_init($url);
$timeout = 900;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, true); </p>
<p>
$response = curl_exec($ch);
curl_close($ch);</p>
<p> return $response;
}</p>
<p>
</p>
<p>$body_data = array(
"request_id" => "하나둘셋",
"pos_type" => "과일"
);</p>
<pre>
<code>get_test_curl($</code>body_data<code>)</code></pre>
<p>
이렇게 데이터를 전송하는데
받는곳에서 한글이 깨진다고 합니다
어떻게 처리를 해야할까요?
아래는 보내는데이터 입니다
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
채택된 답변
+20 포인트
답변에 대한 댓글 3개
�
3년 전
�
3년 전
감사합니다
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
이렇게 해결했습니다 ~~ ^^
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
이렇게 해결했습니다 ~~ ^^
댓글을 작성하려면 로그인이 필요합니다.
3년 전
</p>
<p>// API POST 전송
function api_post($data, $url)
{
$data = json_encode($data);
//echo $data;exit;
$headers[] = "Content-Type: application/json; charset=utf-8";
$headers[] = "Data-Format: json";</p>
<p> $curl = curl_init();</p>
<p> curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_VERBOSE, true);</p>
<p> $response = curl_exec($curl);</p>
<p> curl_close($curl);</p>
<p> $response = json_decode($response, true);</p>
<p> return $response;
}</p>
<p> </p>
<p>$data = array(
'compCd' => '', // 고객사코드 (*필수)
'gprodCd' => '', // 광고제품코드 (*필수)
'siteCd' => '', // 사이트코드 (*필수)
'data' => array(
'inowCd' => '', // 유입코드
'inowUrl' => '', // 유입URL
'accessIp' => $_SERVER['REMOTE_ADDR'], // 접근아이피
'memo' => '', // 비고
'name' => '', // 신청자명 (*필수)
'hp' => '', // 신청자전화번호 (*필수)
'gender' => '', // 신청자성별 (*필수)
'age' => '', // 신청자나이 (*필수)
'104' => '', // 구매목적
'105' => '', // 상담희망시간 (*필수)
'106' => '', // 구매동기 (*필수)
'107' => '', // 비고
) // 요청데이터
);
//print_r($data);exit;</p>
<p>$url = "API호출 주소";
$result = api_post($data, $url); // api 전송
//print_r($result); // 결과값</p>
<p>
이걸로 해보시고, header 부분만 추가해야하면 추가해서 해보세요.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 2개
�
3년 전
답변이 늦었습니다 해당 소스로 변경해도 그렇다고 하네요 ;;
https://pos.gcodesystem.com/img/KakaoTalk_20220808_145343574.png
시도 구군 등 한글로 전송한건 이미지처럼 나오는데.. 이유를 모르겠습니다;;
https://pos.gcodesystem.com/img/KakaoTalk_20220808_145343574.png
시도 구군 등 한글로 전송한건 이미지처럼 나오는데.. 이유를 모르겠습니다;;
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
채택
답변대기
답변대기
답변대기
답변대기
채택
채택
답변대기
답변대기
답변대기
채택
https://pos.gcodesystem.com/img/KakaoTalk_20220808_145343574.png
시도 구군 등 한글로 전송한건 이미지처럼 나오는데.. 왜 그럴까요;;