public static function call($service, $params = array()) { // 缓存时间,大于0时才缓存 $queryCachingDuration = F::sg('cache', 'jpdataCachingDuration'); if ($queryCachingDuration > 0 && self::isCacheService($service)) { $cache = Yii::app()->cache; $cache_key = self::createCacheKey($service, $params); $cache_value = $cache->get($cache_key); if ($cache_value) { return $cache_value; } } //依据service调用不同的方法 $result = APIServer::executeService($service, $params); // 设置缓存 if ($queryCachingDuration > 0 && !empty($result)) { $cache = Yii::app()->cache; $cache->set($cache_key, $result); } if (is_null($result)) { $result = array(); } return $result; }
$corpo = json_decode($corpo); // Controlla che il corpo sia ben formato if (!$corpo) { $corpo = ['raw' => $corpo]; } // Ottiene il SID, se presente if (empty($corpo->sid)) { $sid = null; } else { $sid = (string) $corpo->sid; } // Ottiene API KEY, se presente if (empty($corpo->key)) { $key = false; } else { $key = (string) $corpo->key; } // Ottiene il metodo, se presente if (empty($corpo->metodo)) { $metodo = null; } else { $metodo = (string) $corpo->metodo; } // Dai un nome alla transazione nomeTransazione($metodo, 'api'); // Crea la sessione API $api = new APIServer($key, $sid); // Carica i parametri $api->par = (array) $corpo; // Esegui il metodo richiesto echo $api->esegui($metodo);