A bare bones front-end for knockout designed for maximum compatibility with "obsolete" browsers
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

AbstractData.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Knockout;
  3. class AbstractData {
  4. protected $root;
  5. public function __construct()
  6. {
  7. $this->root = env('KNOCKOUT_API', 'https://api.knockout.chat');
  8. }
  9. private function encodeParameters($parameters = [])
  10. {
  11. $parameters = array_map(function($value, $key) {
  12. return urlencode($key) . '=' . urlencode($value);
  13. }, $parameters, array_keys($parameters));
  14. return '?' . implode('&', $parameters);
  15. }
  16. private function curl($path, $parameters = [])
  17. {
  18. $ch = curl_init(implode(null, [
  19. $this->root, $path, $this->encodeParameters($parameters)
  20. ]));
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  22. curl_setopt($ch, CURLOPT_HEADER, 0);
  23. return $ch;
  24. }
  25. public function httpGet($path, $parameters = [])
  26. {
  27. $ch = $this->curl($path, $parameters);
  28. $data = curl_exec($ch);
  29. curl_close($ch);
  30. return $data;
  31. }
  32. public function httpPost($path, $parameters = [], $properties = [])
  33. {
  34. }
  35. }