public function testToString() { $_SERVER['REQUEST_TIME'] = 1420193419; $text = new Wechat_OutMessage_Text(); $text->setContent('php'); $expRs = "<xml>\n<ToUserName><![CDATA[]]></ToUserName>\n<FromUserName><![CDATA[]]></FromUserName>\n<CreateTime>1420193419</CreateTime>\n<MsgType><![CDATA[text]]></MsgType>\n<Content><![CDATA[php]]></Content>\n<FuncFlag>0</FuncFlag>\n</xml>"; $this->assertEquals($expRs, strval($text)); }
public function response() { try { $rs = $this->run(); if ($rs === NULL) { throw new PhalApi_Exception_BadRequest(T('coming soon!')); } return $rs; } catch (PhalApi_Exception $ex) { $inMessage = new Wechat_InMessage(); $outMessage = new Wechat_OutMessage_Text(); $outMessage->setFromUserName($inMessage->getFromUserName()); $outMessage->setToUserName($inMessage->getToUserName()); $outMessage->setContent($ex->getMessage()); return $outMessage; } catch (Exception $ex) { DI()->logger->error('Wechat Lite caught an exception', $ex->getMessage()); throw new $ex(); } }
protected function hanleWhat($type, $inMessage, &$outMessage) { $outMessage = new Wechat_OutMessage_Text(); $outMessage->setContent('我接收到了信息: ' . $inMessage->getContent()); }