Esempio n. 1
0
 /**
  * 准备消息.
  *
  * @param \Supe\Wechat\Messages\BaseMessage $message
  *
  * @return Broadcast
  */
 public function send($message)
 {
     is_string($message) && ($message = Message::make('text')->with('content', $message));
     if (!$message instanceof BaseMessage) {
         throw new \Exception("消息必须继承自 'Supe\\Wechat\\BaseMessage'");
     }
     $this->message = $message;
     return $this;
 }
Esempio n. 2
0
function messageText($message)
{
    if ($message->Content == 'test') {
        return Message::make('text')->content('Result : ' . print_r($message, 1));
    } elseif ($message->Content == 'qrcode') {
        $qrcode = new QRCode(WX_APPID, WX_APPSECRET);
        $result = $qrcode->temporary(123);
        $qrcodeUrl = $qrcode->show($result->ticket);
        return Message::make('text')->content($qrcodeUrl);
    } else {
        return Message::make('text')->content('您好!欢迎关注“熊喵烘焙”,预订蛋糕可以联系微信号:lisa6036');
    }
}
Esempio n. 3
0
 /**
  * 生成回复内容.
  *
  * @param mixed $response
  *
  * @return string
  */
 protected function response($response)
 {
     if (empty($response)) {
         return '';
     }
     is_string($response) && ($response = Message::make('text')->with('content', $response));
     $return = '';
     if ($response instanceof BaseMessage) {
         $response->from($this->input->get('ToUserName'))->to($this->input->get('FromUserName'));
         $this->call('responseCreated', array($response));
         $return = $response->buildForReply();
         if ($this->security) {
             $return = $this->getCrypt()->encryptMsg($return, $this->input->get('nonce'), $this->input->get('timestamp'));
         }
     }
     $return = $this->call('served', array($return), $return);
     return $return;
 }