[PHP] Curl 을 이용하여 json 을 post 보내기
- 01-19
- 6,373 회
- 0 건
$url : 보낼 주소
$dat : 보낼 데이터
[code]
$url = 'https://abc.com/json';
$dat = ['mode'=>'get'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dat));
$rst = json_decode(curl_exec($ch), true);
curl_close($ch);
[/code]