Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ch = curl_init();
- curl_setopt_array($ch, [
- CURLOPT_URL => $url,
- CURLOPT_TIMEOUT_MS => 500,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => json_encode($data),
- CURLOPT_HTTPHEADER => [
- 'X-Requested-With: XMLHttpRequest',
- 'Content-Type: application/json',
- 'Accept: application/json'
- ],
- CURLOPT_NOSIGNAL =>1;
- ]);
- $response = curl_exec($ch);
- $curl_errno = curl_errno($ch);
- $curl_err = curl_error($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- if ($http_code != 200) {
- log_message('error', 'curl error;curl_errno=' . $curl_errno . ';curl_err=' . $curl_err);
- } elseif (!$result = json_decode($response, true)) {
- log_message('error', 'decode_errno=' . json_last_error() . ';decode_error=' . json_last_error_msg() . ';response=' .$response);
- }
- ......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement