Ejemplo n.º 1
0
 public function get()
 {
     $this->build();
     $resp = Http::get(self::API, $this->param);
     $arr = Json::createFromString($resp)->parse();
     return $arr['ip_list'];
 }
Ejemplo n.º 2
0
 public function get()
 {
     $this->build();
     $resp = Http::get(self::API, $this->param);
     $arr = Json::createFromString($resp)->parse();
     $this->checkError($arr);
     return $arr;
 }
Ejemplo n.º 3
0
 /**
  * @param bool $force
  * @return array|mixed
  * @throws Exception
  */
 private function getData($force = false)
 {
     $resp = null;
     if ($this->useCache && !$force) {
         $resp = $this->getCache()->get($this->cacheKey);
     }
     if ($resp) {
         return $resp;
     }
     $this->build();
     $resp = Http::get(self::API_GET_AT, $this->param);
     if (!$resp) {
         throw new Exception('网络异常,没有获取到任何结果');
     }
     $arr = Json::createFromString($resp)->parse();
     $this->checkError($arr);
     if ($this->useCache) {
         $cache = $this->getCache();
         $cache->setExpires($arr['expires_in']);
         $cache->set($this->cacheKey, $arr);
     }
     return $arr;
 }