data=file_get_contents("php://input"); $header =$this->request->header(); $this->httpClientId=$header['client-id']; $this->httpType=$header['event-type']; $this->httpSign=$header['event-sign']; } public function GetPush(){ if($this->sign() != $this->httpSign) { // sign校验失败, 自行检查 return json_encode(array("code" => 0, "msg" => "faild")); } $httpData = json_decode($this->data, true); // 业务逻辑处理 // 根据 Type 来识别消息事件类型, 具体的 type 值以文档为准, 此处仅是示例 if($this->httpType == "POINTS") { // 建议异步处理业务逻辑 // http request body // msg内容经过 urlencode 编码,需进行解码 $msg = json_decode(urldecode($httpData['msg']), true); //todo } // 响应结果 return json_encode(array("code" => 0, "msg" => "success")); } public function sign(){ return md5(sprintf('%s%s%s', $this->clientId, $this->data, $this->clientSecret)); } }