22 lines
629 B
PHP
22 lines
629 B
PHP
|
<?php
|
||
|
|
||
|
// === cURL helper function ===
|
||
|
function curlPost($url, $data, $headers = []) {
|
||
|
$ch = curl_init($url);
|
||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
|
||
|
'Content-Type: application/x-www-form-urlencoded',
|
||
|
'User-Agent: curl/7.64.1'
|
||
|
], $headers));
|
||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||
|
$response = curl_exec($ch);
|
||
|
if (curl_errno($ch)) {
|
||
|
die("cURL error: " . curl_error($ch) . "\n");
|
||
|
}
|
||
|
curl_close($ch);
|
||
|
return json_decode($response, true);
|
||
|
}
|
||
|
|
||
|
?>
|