Ejemplo n.º 1
0
 /**
  * Transform articles message.
  *
  * @return array
  */
 public function tranformArticles(AbstractMessage $message)
 {
     $articles = [];
     foreach ($message->all() as $item) {
         $articles[] = ['Title' => $item->title, 'Description' => $item->description, 'Url' => $item->url, 'PicUrl' => $item->pic_url];
     }
     return ['ArticleCount' => count($articles), 'Articles' => $articles];
 }
Ejemplo n.º 2
0
 /**
  * Build reply XML.
  *
  * @param string          $to
  * @param string          $from
  * @param AbstractMessage $message
  *
  * @return string
  */
 protected function buildReply($to, $from, $message)
 {
     $base = ['ToUserName' => $to, 'FromUserName' => $from, 'CreateTime' => time(), 'MsgType' => $message->getType()];
     $transformer = new Transformer();
     return XML::build(array_merge($base, $transformer->transform($message)));
 }
Ejemplo n.º 3
0
 /**
  * Transform material message.
  *
  * @return array
  */
 public function transformMaterial(AbstractMessage $message)
 {
     return [$message->getType() => ['media_id' => $message->media_id]];
 }
Ejemplo n.º 4
0
 /**
  * Transform material message.
  *
  * @return array
  */
 public function transformMaterial(AbstractMessage $message)
 {
     $type = $message->getType();
     return ['msgtype' => $type, $type => ['media_id' => $message->get('media_id')]];
 }
Ejemplo n.º 5
0
 /**
  * Transform transfer message.
  *
  * @return array
  */
 public function transformTransfer(AbstractMessage $message)
 {
     $response = [];
     // 指定客服
     if ($message->get('account')) {
         $response['TransInfo'] = ['KfAccount' => $message->get('account')];
     }
     return $response;
 }
Ejemplo n.º 6
0
 public function transformDeviceText(AbstractMessage $message)
 {
     $response = ['DeviceType' => $message->get('device_type'), 'DeviceID' => $message->get('device_id'), 'SessionID' => $message->get('session_id'), 'Content' => base64_encode($message->get('content'))];
     return $response;
 }