diff --git a/WeChat/Contracts/Tools.php b/WeChat/Contracts/Tools.php index b919e5c..fda7e90 100644 --- a/WeChat/Contracts/Tools.php +++ b/WeChat/Contracts/Tools.php @@ -150,7 +150,7 @@ class Tools $entity = libxml_disable_entity_loader(true); $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); libxml_disable_entity_loader($entity); - return json_decode(self::arr2json($data), true); + return json_decode(json_encode($data), true); } /** @@ -162,7 +162,7 @@ class Tools { return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) { return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE"); - }, ($jsonData = json_encode($data)) == '[]' ? '{}' : $jsonData); + }, ($json = json_encode($data)) == '[]' ? '{}' : $json); } /** diff --git a/composer.json b/composer.json index 0e8cfa4..d8ee7c1 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,10 @@ "php": ">=5.4", "ext-json": "*", "ext-curl": "*", - "ext-openssl": "*" + "ext-libxml": "*", + "ext-openssl": "*", + "ext-mbstring": "*", + "ext-simplexml": "*" }, "autoload": { "classmap": [