db = \Zend_Registry::get('db'); }else{ $this->db = $db; } $this->config = \Zend_Registry::get('config'); $this->table = new Table(); } //根据ID或者Client_id获得app的信息 public function getClientInfo($id) { if(empty($id)) { return "无效参数"; } if(is_numeric($id)) { $field = "id"; }else{ $field = "client_id"; } $sql = "SELECT * FROM {$this->table->oauth_clients} WHERE $field=? LIMIT 1"; $sth = $this->db->prepare($sql); $sth->execute(array($id)); $row = $sth->fetch(); return $row; } //验证App public function clientCredentials($client_id,$client_secret) { $client = $this->getClientInfo($client_id); if(empty($client['id'])) { return "此应用ID未被证实"; } if($client['status'] == -1) { return "此应用已关闭"; } if($client['client_secret'] !== $client_secret) { return "Invalid client secret"; } return true; } }