카카오톡 채널관리자 API문서를 보고 유저 파일을 생성하였습니다.
그리고 조회했을때로 정상적으로 제가 생성한 file_id 를 리턴 받습니다.
문제는 해당 file_id 로 유저를 추가하는 코드를 보냈을때는 아무런 반응이 없습니다.
API 문서에는 원래 리턴값은 없다 써있기는 하지만 아래의 이미지에는 등록 성공수나 친구수가 떠야 하지 않나요?
등록 시도수 조차도 변동이 없기에 왜 이런 것인지 궁금합니다.
제가 작성한 코드들을 아래 표기해 드립니다.
※고객파일 조회 소스코드
// 기록을 할 고객 파일을 조회합니다.
$hostUrl = “https://kapi.kakao.com”;
$requestUrl= “/v1/talkchannel/target_user_file”;
$KakaoAK = “9c452c30fc280cf2696b4864ecf103e9”;
$channel_public_id = “_xbxfyxeT”;
$url = $hostUrl.$requestUrl."?channel_public_id=".$channel_public_id;
//$schema = array(‘rType’=>‘string’,‘managerId’=>‘string’,‘cName’=>‘string’,‘cHp’=>‘string’,‘cOpen’=>‘string’,‘cLocal’=>‘string’);
//$schema_json = json_encode($schema);
//$data = array(‘channel_public_id’=>’_xbxfyxeT’,‘file_name’=>‘랜딩DB연동’,‘schema’=>$schema_json);
//$data_json = json_encode($data, JSON_UNESCAPED_UNICODE);
try {
$is_post = false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array();
$headers[] = "Authorization: KakaoAK " .$KakaoAK;
$headers[] = “Content-Type: application/json”;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec ($ch);
$response = json_decode($response, true);
print_r($response);
} catch(Exception $E) {
echo "Response: ". $E->lastResponse . “\n”;
}
#유저정보 입력용 소스코스
// 고객 파일에 유저정보를 입력합니다.
$hostUrl = “https://kapi.kakao.com”;
$requestUrl= “/v1/talkchannel/update/target_users”;
$KakaoAK = “9c452c30fc280cf2696b4864ecf103e9”;
$channel_public_id = “_xbxfyxeT”;
$url = $hostUrl.$requestUrl;
$insertData = array(‘cTel’=>‘01074453305’, ‘cBrand’=>‘zero100’, ‘cDate’=>‘2019-10-31T16:08:34’, ‘cName’=>‘김테스트’, ‘cManager’=>‘홍길동’, ‘cStatus’=>‘배정’, ‘cLocal’=>‘서울’, ‘cOpen’=>‘6개월’, ‘cCate’=>‘pcQ’);
$fieldData = array();
$fieldData[] = array(‘id’=>‘01074453305’,‘field’=>$insertData);
$data = array(‘file_id’=>‘6401’,‘channel_public_id’=>$channel_public_id,‘user_type’=>‘app’,‘users’=>$fieldData);
$data_json = json_encode($data, JSON_UNESCAPED_UNICODE);
try {
$is_post = true;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array();
$headers[] = "Authorization: KakaoAK " .$KakaoAK;
$headers[] = “Content-Type: application/json”;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec ($ch);
$response = json_decode($response, true);
print_r($response);
} catch(Exception $E) {
echo "Response: ". $E->lastResponse . “\n”;
}