public function dispatch($input) { if (!isset($input['signature'])) { throw new Duoshuo_Exception('Invalid signature.', Duoshuo_Exception::INVALID_SIGNATURE); } $signature = $input['signature']; unset($input['signature']); ksort($input); $baseString = http_build_query($input, null, '&'); $expectSignature = base64_encode(Duoshuo_Abstract::hmacsha1($baseString, $this->plugin->getOption('secret'))); if ($signature !== $expectSignature) { throw new Duoshuo_Exception('Invalid signature, expect: ' . $expectSignature . '. (' . $baseString . ')', Duoshuo_Exception::INVALID_SIGNATURE); } $method = $input['action']; if (!method_exists($this, $method)) { throw new Duoshuo_Exception('Unknown action.', Duoshuo_Exception::OPERATION_NOT_SUPPORTED); } $this->response = array(); $this->{$method}($input); $this->sendResponse(); }