/**
  * @throws Exception
  */
 public function checkArrayException($array)
 {
     if (false === $this->checkArray($array)) {
         $e = new Exception('签名检查失败');
         $e->setData($array);
         throw $e;
     }
 }
Exemple #2
0
 public function checkErrorAndException()
 {
     if ($this->isError()) {
         $e = new Exception('微信发生错误: ' . $this->getErrorMessage());
         $e->setData($this);
         throw $e;
     }
 }
Exemple #3
0
 /**
  * @param string $xml
  * @throws \Chuntent\Extension\Tools\Weixin\Exception
  * @return \Chuntent\Extension\Tools\Weixin\Message
  */
 public function createByXmlString($xml)
 {
     $simple = simplexml_load_string($xml);
     if (empty($simple)) {
         $e = new Exception('xml文件错误');
         $e->setData($xml);
         throw $e;
     }
     $type = (string) $simple->MsgType;
     $class = __CLASS__ . ucfirst($type);
     if (class_exists($class)) {
         return new $class($simple);
     } else {
         return new self($simple);
     }
 }