Example #1
0
 public function __construct($iniFile)
 {
     $this->loadBaseMods();
     $this->loadIni($iniFile);
     $this->pdo = new lw\Pdo($this, $this->configArray['Pdo']);
     $this->curl = new \Curl\Curl();
     //Set this option because WAMP sucks
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     //Set this because all the returns are expecting JSON string, and Curl updated to do it automatically.
     $this->curl->setJsonDecoder(function ($response) {
         return $response;
     });
     $this->url = $this->configArray['Site']['url'];
     $this->title = $this->configArray['Site']['title'];
     Core::setApiKey($this->configArray['Site']['APIKEY']);
 }
Example #2
0
 protected function getApi($id)
 {
     $url = Core::$API_HOST . "item/{$id}";
     $url = Core::urlAddKey($url);
     $this->curl->get($url);
     $json = $this->curl->response;
     $jArray = json_decode($json, true);
     if (isset($jArray['status']) && $jArray['status'] == 'nok') {
         //Status error, update current item to reflect, and return
         $this->_empty();
         $this->data['lastUpdate'] = null;
         $this->data['fullJSON'] = $json;
         $this->site->debug->notice("wowItem({$id}) does not exist");
         return null;
     }
     foreach ($jArray as $key => $value) {
         parent::__set($key, $value);
     }
     $this->data['lastUpdate'] = time();
     $this->data['fullJSON'] = $json;
     $this->saveItem();
     //$this->saveIcon();
     $this->site->debug->notice("Updated Item({$id}) from API");
 }