loadXML($xmltext); $array_e = $xml->getElementsByTagName('Encrypt'); $array_a = $xml->getElementsByTagName('ToUserName'); $encrypt = $array_e->item(0)->nodeValue; $tousername = $array_a->item(0)->nodeValue; return array(0, $encrypt, $tousername); } catch (Exception $e) { //print $e . "\n"; return array(ErrorCode::$ParseXmlError, null, null); } } /** * 生成xml消息 * @param string $encrypt 加密后的消息密文 * @param string $signature 安全签名 * @param string $timestamp 时间戳 * @param string $nonce 随机字符串 */ public function generate($encrypt, $signature, $timestamp, $nonce) { $format = " %s "; return sprintf($format, $encrypt, $signature, $timestamp, $nonce); } } ?>