note 127267 deleted from book.curl by cmb

From: Date: Tue, 12 Jul 2022 08:46:24 +0000
Subject: note 127267 deleted from book.curl by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218983@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- function curl_request($url, $method = 'get', $data = [], $type = 'https') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (strtolower($method == 'post')) { $data = json_encode($data); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } if (strtolower($type) == 'https') { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } $result = curl_exec($ch); if ($result == null || $result === false) { print_r(curl_error($ch)); } curl_close($ch); return $result; }

« previous php.notes (#218983) next »