示例#1
0
文件: Site.php 项目: boehsermoe/luya
 public function getRemote()
 {
     $url = Url::trailing($this->url);
     $data = Yii::$app->cache->get($url);
     if ($data === false) {
         $curl = new \Curl\Curl();
         if ($this->auth_is_enabled) {
             $curl->setBasicAuthentication($this->auth_user, $this->auth_pass);
         }
         $curl->get($url . 'admin/api-admin-remote?token=' . sha1($this->token));
         if ($curl->error) {
             $data = false;
         } else {
             $data = json_decode($curl->response, true);
         }
         Yii::$app->cache->set($url, $data, 60 * 2);
     }
     return $data;
 }