cleaner login process
This commit is contained in:
parent
dee2522676
commit
920c8932a0
3 changed files with 47 additions and 28 deletions
21
utils.php
Normal file
21
utils.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue