PHP

[PHP] CURL 사용법, data 전송 / 받기

은둔한량 2023. 9. 1. 17:12
반응형

CURL 기본 사용법

<?php
$data = array(
    'id' => 'id',
    'pw' => 'pw'
);
$url = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$data=json_decode($response, true);

print_r($data);

?>
반응형