| <?php
|
| set_time_limit(0);
|
| ini_set('memory_limit', '2256M');
|
| CHAT_KEY = 'key'
|
| try {
|
| $payload = "GET ALL DATA";
|
|
|
| $ch = curl_init("https://url");
|
| curl_setopt_array($ch, [
|
| CURLOPT_RETURNTRANSFER => true,
|
| CURLOPT_POST => true,
|
| CURLOPT_HTTPHEADER => [
|
| "Content-Type: application/json", "Authorization: Bearer " . CHAT_KEY
|
| ],
|
| CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
|
| CURLOPT_TIMEOUT => 1000,
|
| CURLOPT_FAILONERROR => true
|
| ]);
|
|
|
| $response = curl_exec($ch);
|
| curl_close($ch);
|
|
|
| $decoded = json_decode($response, true);
|
|
|
| $content = $decoded['choices'][0]['message']['content'];
|
| echo $content;
|
|
|
|
|
| } catch (Throwable $e) {
|
| // This guarantees something shows up instead of silent 500
|
| error_log($e->getMessage());
|
|
|
| echo $e->getMessage();
|
| }
|