View - Download - Fork Generated with ♥ by Pastecloud.net
  1. <?php
  2.  
  3. /**
  4.  * Class MinecraftKrant
  5.  *
  6.  * @package MinecraftKrant
  7.  * @author  MinecraftKrant
  8.  * @website https://www.minecraftkrant.nl
  9.  * @version 1.0
  10.  */
  11. class MinecraftKrant
  12. {
  13.     private $client;
  14.     private $baseUrl = 'https://www.minecraftkrant.nl/api/news';
  15.  
  16.     public function __construct()
  17.     {
  18.         $this->client = curl_init();
  19.  
  20.         curl_setopt($this->client, CURLOPT_RETURNTRANSFER, true);
  21.     }
  22.  
  23.     public function send($parameter = '')
  24.     {
  25.         curl_setopt($this->client, CURLOPT_URL, $parameter ? $this->baseUrl . '/' . $parameter : $this->baseUrl);
  26.  
  27.         return json_decode(curl_exec($this->client));
  28.     }
  29.  
  30.     public function get($slug = '')
  31.     {
  32.         return $this->send($slug);
  33.     }
  34. }